2

Is there a better way to view the IP address assigned to cluster IP address resource through PowerShell?

Today, I use Get-ClusterResource, but I have to populate the cluster IP address resource name field with the IP address. That seems weird to me, but it works.

Here is how I get the IP addresses now:

PS C:\Users\Administrator> Get-ClusterResource

Name                    State  OwnerGroup    ResourceType
----                    -----  ----------    ------------
Cluster Name            Online Cluster Group Network Name
IP Address 10.10.10.x Online SRXSVC        IP Address
IP Address 10.10.10.y Online Cluster Group IP Address
IP Address 10.20.70.z Online SRXSVC        IP Address
ptay
  • 131
  • 1
  • 1
  • 6
  • 1
    Welcome to ServerFault. You ask for a "better way". Can you show us the code you currently use? Without knowing that, it's hard to propose something "better". – Doug Deden Apr 08 '19 at 20:32
  • I use "Get-ClusterResource | SLS 'IP Address'" and get list of IP address that I parse. I put example in original question. – ptay Apr 08 '19 at 22:11

3 Answers3

3

This will be a little bit cleaner. It'll return just the IP address.

get-clusterresource -name "cluster ip address" | get-clusterparameter -name Address | select -Property Value

Returns:

Value
-----
172.16.100.204
Doug Deden
  • 1,844
  • 7
  • 10
  • I get an error when I run the command. get-clusterresource : An error occurred opening resource 'cluster ip address'. At line:1 char:1 + get-clusterresource -name "cluster ip address" | get-clusterparameter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (:) [Get-ClusterResource], ClusterCmdletException + FullyQualifiedErrorId : ClusterObjectNotFound,Microsoft.FailoverClusters.PowerShell.GetResourceCommand – ptay Apr 10 '19 at 00:25
2

I think this is the best way to retrieve the cluster IP address without using explicit names:

Get-ClusterGroup | Where-Object { $_.GroupType -eq "Cluster" } |
    Get-ClusterResource | Where-Object { $_.ResourceType -eq "IP Address" } |
    Get-ClusterParameter -Name "Address" | 
    Select-Object -ExpandProperty "Value"
mhu
  • 123
  • 5
1

You can use the following to return the IP address(es):

Get-ClusterResource | Where { $_.ResourceType -eq "IP Address" } | Get-ClusterParameter -Name "Address" | Select ClusterObject, Value
Tim Liston
  • 736
  • 3
  • 8