取出根路径

1 $text = "\127.0.0.1D$HotfixHotfix_Win20032014-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.1D$

判断路径:

test-path "filesystem::\127.0.0.1d$"

原文地址:https://www.cnblogs.com/dreamer-fish/p/3927153.html