Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

powershell get sql virtual

Hello,

When I execute this powershell function :

function Get-ClusterSQL
{
    param($cluster)
   
    gwmi -class "MSCluster_Resource" -namespace "root\mscluster" -computername $cluster  | where {$_.type -eq "SQL Server"} | Select @{n='VirtualServerName';e={$_.PrivateProperties.VirtualServerName}}, @{n='InstanceName';e={$_.PrivateProperties.InstanceName}}, `
    @{n='ServerInstance';e={("{0}\{1}" -f $_.PrivateProperties.VirtualServerName,$_.PrivateProperties.InstanceName).TrimEnd('\')}}
   
}

The result is

VirtualServerName                       InstanceName                            ServerInstance
-----------------                       ------------                            --------------
Test                                    Test12                                  Test\Test12

How can I modify the function for having the result test\test12?

Thanks

Regards

bibi
Avatar of TempDBA
TempDBA
Flag of India image

Not clear with your question. Please explain a bit more.
Avatar of bibi92

ASKER

I search how I can modify the function for display only test\test12 and not
ServerInstance
--------------
test\test12
Thanks
bibi
Avatar of SubSun
Does this work?
Get-ClusterSQL Cluster | Select -ExpandProperty ServerInstance
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bibi92

ASKER

Thanks regards bibi