2024-07-11 18:33:30 +00:00
|
|
|
function Get-Hostname ($name) {
|
|
|
|
|
if ($name.Length -eq 5) {
|
|
|
|
|
$res = Get-AssetConversion $name
|
|
|
|
|
if ($res) { return $res }
|
|
|
|
|
}
|
|
|
|
|
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
|
|
|
|
|
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
|
|
|
|
$res = Resolve-DnsName $name
|
|
|
|
|
if ($res -and $res.NameHost -and ($res.NameHost -match "([^.]*)\.int\.samhealth\.net")) {
|
|
|
|
|
return $Matches[1]
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-12 20:50:15 +00:00
|
|
|
if ($name.Length -eq 7) {
|
|
|
|
|
$res = Get-ServiceTagConversion $name
|
|
|
|
|
if ($res) { return $res }
|
|
|
|
|
}
|
2024-07-11 18:33:30 +00:00
|
|
|
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
|
|
|
|
|
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
2024-07-12 20:50:15 +00:00
|
|
|
$res = Get-SCCM_PCFromMAC $name
|
|
|
|
|
if ($res) { return $res }
|
2024-07-11 18:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $name
|
|
|
|
|
}
|