Converting the FileSystemObject's GetDriveName Method

Definition: Given a path, returns the drive letter.

GetDriveName

Use the -qualifier parameter with the Split-Path cmdlet to return only the drive letter.

PS C:\scripts> Split-Path "C:\scripts\test.txt" -qualifier
C:

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