获得windows群集中的VM数
获取远程Hyper-V主机上运行中的VM
1 $password = ConvertTo-SecureString Passw0rd -AsPlainText -Force 2 $cre = New-Object System.Management.Automation.PSCredential thincl\administrator,$password 3 4 $HV = New-PSSession -ComputerName HV01 -Credential $cre 5 or:$s1, $s2, $s3 = New-PSSession -ComputerName Server01,Server02,Server03 6 Enter-PSSession -Session $HV 7 $HV01_Count=get-vm w-* | where-object{$_.State -eq "Running"} 8 Exit-PSSession
获取远程Hyper-V主机上运行中的VM(排序)
1 $HVServer='HV01' 2 $Running_VM_Count=Invoke-Command -ScriptBlock { get-vm w-* | where-object{$_.State -eq "Running"} | sort-object Name | Select Name } -ComputerName $HVServer
获取群集中的VM数:
1 Get-ClusterGroup | ?{$_.GroupType -eq 'VirtualMachine'} | Get-VM
指定群集
1 Get-ClusterGroup -Cluster HVCluster | ?{$_.GroupType -eq 'VirtualMachine'} | Get-VM
------山的那一边

浙公网安备 33010602011771号