取出根路径
1 $text = "\\127.0.0.1\D$\Hotfix\Hotfix_Win2003\2014-04" 2 $pathRoot = [System.IO.Path]::GetPathRoot($text) 3 $driverLetter = $pathRoot[-2] 4 Join-Path ("$driverLetter" + ":") $text.Substring($pathRoot.Length, $text.Length - $pathRoot.Length)
$pathRoot的返回值为:\\127.0.0.1\D$
判断路径:
test-path "filesystem::\\127.0.0.1\d$"