Created
April 13, 2020 19:31
-
-
Save dpo007/6a356b138610f38dfaf2c4d9362e327e to your computer and use it in GitHub Desktop.
PowerShell Function :: Get HostName From UNC Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetHostNameFromUNC { | |
param ( | |
[Parameter(Mandatory=$true)] | |
[string]$UNCPath | |
) | |
$UNCPath -match '\\\\(.*?)\\' | Out-Null | |
if ($Matches.Count -ge 2) { | |
return $Matches[1] | |
} else { | |
return $null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment