Converting the FileSystemObject's Drives Property

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


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


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:


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