A problem that I often have is trying to get the UNC path for a mapped drive so that I can pass it to somebody or that they can pass the UNC path to me. My ideal solution would be to execute a command passing the drive letter as an argument and having the UNC path copied to the clipboard so that I can then paste the UNC path in an email or instant message, so I wrote the following script using PowerShell and the PowerShell community extensions (PSCX).
If you don't already have them installed install the following:
Then save my script to a folder on your computer and run it as follows
Where 'z' is the drive letter for the mapped drive, the UNC path will then be on your clipboard and you can then paste it wherever you like.
[string] $Drive = "Z:"
# ensure the supplied param ends with ':'
$Drive = $Drive.ToUpper().ToCharArray() + ":"
$logicalDisk = Gwmi Win32_LogicalDisk -filter "DriveType = 4 AND DeviceID = '$Drive'"