取出根路径

 

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$"

posted on 2014-08-21 14:37  momingliu11  阅读(185)  评论(0编辑  收藏  举报