Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Converting the FileSystemObject's GetDrive Method

Windows PowerShell

Definition: Returns an instance of the Drive object associated with the given path.


The most reliable way to do this in PowerShell is to use the .NET Framework object System.IO.DriveInfo to retrieve information about a particular drive.

$d = New-Object -typename System.IO.DriveInfo -argumentlist "C:"

This doesn’t work with network shares (i.e., \\atl-fs-01\scripts), it works only with mapped drive letters.

You can retrieve drive properties from all drives, including PowerShell drives such as registry drives, by using the Get-PSDrive cmdlet.

Get information about all drives:


Get information about the C: drive:

Get-PSDrive c

You can retrieve a list of all the actual drives (not including PowerShell drives) on the computer by once again using the .NET Framework:


See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft