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 Server Clustering
Windows Server Clustering
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Clustering: The grouping of multiple servers in a way that allows them to appear to be a single unit to client computers on a network. Clustering is a means of increasing network capacity, providing live backup in case one of the servers fails, and improving data security.
969 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,433 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,701 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:
    https://www.powershellbros.com/powershell-tip-of-the-week-get-fqdn

    ----------

    (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