Skip to content

Instantly share code, notes, and snippets.

@AdamDimech
Created February 22, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamDimech/2c2dadeed1f7bbb1f3f2da7b59ce3dc9 to your computer and use it in GitHub Desktop.
Save AdamDimech/2c2dadeed1f7bbb1f3f2da7b59ce3dc9 to your computer and use it in GitHub Desktop.
Determine an UNC path from a local path
$currentDirectory = Get-Location
$currentDrive = Split-Path -qualifier $currentDirectory.Path
$logicalDisk = Gwmi Win32_LogicalDisk -filter "DriveType = 4 AND DeviceID = '$currentDrive'"
$unc = $currentDirectory.Path.Replace($currentDrive, $logicalDisk.ProviderName)
$output = "`r`n`r`nThe UNC Path for " + $currentDirectory + " is " + $unc
$output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment