- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to eject the USB device from the system using PowerShell?
To eject the USB device from the system, we first need to get the USB device using PowerShell. WMI class Win32_Volume will help us to find the USB device.
We know that all removal devices using the DriveType '2'. So we will filter out the USB device among the listed devices.
PS C:\> $usbdev = gwmi win32_volume | where{$_.DriveType -eq '2'}
The below commands will helpful to unallocated the USB from the system.
PS C:\> $usbdev.DriveLetter = $null PS C:\> $usbdev.Put()
Output
Path : \localhost\root\cimv2:Win32_Volume.DeviceID="\\?\Volume{6e4d6f1e-a8c2-11eb-9493-005056c00008}\" RelativePath : Win32_Volume.DeviceID="\\?\Volume{6e4d6f1e-a8c2-11eb-9493-005056c00008}\" Server : localhost NamespacePath : root\cimv2 ClassName : Win32_Volume IsClass : False IsInstance : True IsSingleton : False
And the below command will dismount the disk from the system.
PS C:\> $usbdev.Dismount($false,$false) | Out-Null
You can find the method Dismount details for the Removal Disk is as below.
- Related Articles
- How to check if the USB device is connected to the system using PowerShell?
- How to find the device driver version using PowerShell?
- How to delete the local group from the windows system using PowerShell?
- How to make a USB device multi-touch enabled
- How to find the MAC address of the system using PowerShell?
- How to change pagefile settings from custom to system managed using PowerShell?
- How to get the system files using the Get-ChildItem in PowerShell?
- How to get all the user profiles on the System using PowerShell?
- How to retrieve the Operating system of the Azure VM using PowerShell?
- How to mount usb drive in a linux system
- How to block ports on the Windows Operating System using PowerShell?
- How to get the device major number from a raw device number using Python?
- How to restart a remote system using PowerShell?
- How to open a port in the Windows Operating System using PowerShell?
- How to get the System uptime with PowerShell?

Advertisements