How do I test-path using UNC rather than mapped letter drive
This returns True
Test-Path -Path Y:\FNDDEV
Windows explorer
PC > EAMDEV(\\Eamcifsdev.lirrad.lirr.org) (Y:) > FNDDEV
How do I test-path using UNC rather than mapped letter drive
This returns True
Test-Path -Path Y:\FNDDEV
Windows explorer
PC > EAMDEV(\\Eamcifsdev.lirrad.lirr.org) (Y:) > FNDDEV
If you are looking for the UNC path of a network drive just use Get-PSDrive. It will gather all of the information about a drive including the provider, root, current location, used space, free space, and name.
$drive = Get-PSDrive -Name (get-location).Drive.Name
For instance the name parameter is used as the current drive letter by using Get-Location.
$root = if($drive.DisplayRoot -ne $null){$drive.DisplayRoot} else {$drive.Root}
We compare the .Root data with the drive letter and network location. .DisplayRoot gives us the network location / network path. .Root gives us the drive letter. It will be Null if it is a local path as there is no .DisplayRoot to provide.
Join-Path -Path $root -ChildPath $drive.CurrentLocation
Lastly using Join-Path put it all together to give the network path and current location if it is a mapped drive. If not you will get just the drive letter.
I got this to work with UNC formatted as follows:
\Eamcifsdev.lirrad.lirr.org\EAMDEV\FNDDEV\docuploads\MTADEV4\Backup
thanks for responding