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
.\DrivePath z
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.
param( [Parameter(position=0, Mandatory=$true)] [string] $Drive = "Z:" ) # ensure the supplied param ends with ':' $Drive = $Drive.ToUpper().ToCharArray()[0] + ":" $logicalDisk = Gwmi Win32_LogicalDisk -filter "DriveType = 4 AND DeviceID = '$Drive'" out-clipboard $logicalDisk.ProviderName
.Net (4) ASP.Net (6) ASP.Net MVC (3) Best Practice (2) Book (4) Burn CD/DVD (1) C# (5) Career (2) Class Library (1) Community event (14) Design (1) Design Patterns (1) Ethernet (1) Home Network (1) i18n (1) Internet Explorer (1) iPod (1) JavaScript (2) jQuery (1) Library (1) Microsoft Translator (1) Ms Office (1) MVC Unit test (1) NWMTUG (6) Open Source (2) PowerShell (13) Python (1) SharePoint (1) SQL Server (1) Team System (1) Test Driven Development (7) Utility (14) Visual C++ (1) Visual Studio 2008 (11) Windows 64 bit (1) Windows 7 (10) Windows XP (3)