Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Converting the FileSystemObject's ShareName Property

Windows PowerShell

Definition: Given a Drive, returns the name of the network share.


We’re going to take the easy way out on this one and simply use the FileSystemObject from within PowerShell:

$a = New-Object -ComObject Scripting.FileSystemObject
$d = $a.GetDrive("Z:\")

Here we’re creating an instance of the FileSystemObject by passing it with the -ComObject parameter to the New-Object cmdlet. We then get the drive that’s mapped to a network share by calling the GetDrive method. After that all we have to do is display the ShareName property.

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