bibi92
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= {$_.Privat ePropertie s.VirtualS erverName} }, @{n='InstanceName';e={$_.P rivateProp erties.Ins tanceName} }, `
@{n='ServerInstance';e={(" {0}\{1}" -f $_.PrivateProperties.Virtu alServerNa me,$_.Priv atePropert ies.Instan ceName).Tr imEnd('\') }}
}
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
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=
@{n='ServerInstance';e={("
}
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
Not clear with your question. Please explain a bit more.
ASKER
I search how I can modify the function for display only test\test12 and not
ServerInstance
--------------
test\test12
Thanks
bibi
ServerInstance
--------------
test\test12
Thanks
bibi
Does this work?
Get-ClusterSQL Cluster | Select -ExpandProperty ServerInstance
Get-ClusterSQL Cluster | Select -ExpandProperty ServerInstance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks regards bibi