Skip to content

Instantly share code, notes, and snippets.

@wsmelton
Created February 18, 2022 14:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wsmelton/4fd1314138a10f02d709fa2aa5cf0cee to your computer and use it in GitHub Desktop.
[cmdletbinding()]
param(
[string]
$VMName
)
$scriptBlock = {
$clusterNetworkNames = Get-ClusterResource | Where-Object ResourceType -eq 'Network Name'
foreach ($n in $clusterNetworkNames) {
if ($n.Name -match 'SQL Network Name') {
$hostValue = $n.Name.TrimStart('SQL Network Name (').TrimEnd(')')
$fqdn = [System.Net.Dns]::GetHostByName($hostValue).Hostname
} else {
$fqdn = [System.Net.Dns]::GetHostByName($n.Cluster).Hostname
}
[pscustomobject]@{
ClusterName = $n.Cluster
Name = $n.Name
OwnerNode = $n.OwnerNode
FQDN = $fqdn
}
}
}
try {
Invoke-Command -ComputerName $VmName -ScriptBlock $scriptBlock -ErrorAction Stop | Format-Table ClusterName, Name, OwnerNode, FQDN
} catch {
throw "Issue connecting to $VMName - $($_)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment