Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Formatting output to pass as part of a where clause from Select_Object

$
0
0
I am really new to PS and I am trying to write a script to set up our AGs with RegisterProviderAllIPs = 0. In order to do this, I need to get the name of the Network Name associated with the AG. For this I start by determining the name of the AG:[code="vb"]Get-ClusterResource | Where-Object -Property ResourceType -EQ "SQL Server Availability Group" | Select-Object Name[/code]That's all fine, but I want to save that into a variable and then use the variable to filter in order to find the Network Name where I will set the cluster parameters:[code="vb"]$AGName = Get-ClusterResource | Where-Object -Property ResourceType -EQ "SQL Server Availability Group" | Select-Object NameGet-ClusterResource | Where-Object {$_.OwnerGroup -EQ $AGName -AND $_.ResourceType -EQ "Network Name"} | Select-Object Name[/code]However, this is failing because $AGName is not literally just the string of the name. It is "Name: Agname" How can I set this up properly?

Viewing all articles
Browse latest Browse all 467

Trending Articles