Need help to get FQDN using PS command to extract network name resource of a Role running in Failover Cluster Manager

Surabhi Jaiswal 41 Reputation points
2021-02-10T07:56:29.453+00:00

I already have a complex command to get server name of a Role running in my application failover cluster. But now I want to modify it to get FQDN for the same server name in one line.

Below is the command which fetches me the servername. How do I modify it to get FQDN?

(Get-ClusterResource | Where-Object {$.ResourceType.Name -eq "Network Name" -and $.OwnerGroup -eq (Get-ClusterResource | Where-Object {$.ResourceType.Name -eq "Generic Service" -and $.Name -like "Rhapsody*"} ).OwnerGroup.Name}).name

Thanks in advance!!

-Surabhi

Windows for business | Windows Server | Storage high availability | Clustering and high availability
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Answer accepted by question author
  1. Leon Laude 86,086 Reputation points
    2021-02-10T08:05:54.983+00:00

    Hi @Surabhi Jaiswal ,

    Your PowerShell command seems to be missing something as it's not working here.

    To get the FQDN, you could refer to the following article:

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Best regards,
    Leon

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Shawn Melton 11 Reputation points
    2022-02-18T14:40:19.74+00:00

    Method I've used:

    Get-ClusterResource | Where-Object ResourceType -eq 'Network Name' | Select-Object Cluster, Name, OwnerNode, @{L='FQDN';E={if ($_.Name -match 'SQL Network Name') {[System.Net.Dns]::GetHostByName($_.Name.TrimStart('SQL Network Name (').TrimEnd(')')).HostName} else {[System.Net.Dns]::GetHostByName($_.Cluster).Hostname}}}
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.