Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's Drives Property


Windows PowerShell


Definition: Returns a collection of all the drives available on the local computer.

Drives


The .NET Framework makes this pretty simple in PowerShell. All you need to do is reference the DriveInfo class and call the GetDrives method:


[System.IO.DriveInfo]::GetDrives()


Notice that we didn’t need to call the New-Object cmdlet to create an instance of the DriveInfo class. That’s because we’re getting information about all the drives, we don’t want information about a specific drive.

You can also use the Get-PSDrive cmdlet to return all the PowerShell drives:


Get-PSDrive


This cmdlet will include “drives” such as registry drives and environment drives.


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
Show:
© 2014 Microsoft