Striping servername from a UNC path
PS> $path = \\chicken\scrambled
PS >$servername=$path.Substring(2,$path.Substring(2).indexof("\"))
PS>$servername
chicken
2,$path.Substring(2).indexof("\")
=
2 # start cut @ position 2
$path.Substring(2) #then search from 2 position
.indexof("\") # search for \ in postion
My regex query to get server name
$path -match "[^/\\\]\[]+"
$matches.Values
No comments:
Post a Comment