Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's ShareName Property


Windows PowerShell


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

ShareName


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:\")
$d.ShareName


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