Powercli examples
Jump to navigation
Jump to search
auth to api
$vCenters = @("vmc01", "vmc02") Connect-VIServer -Server $vCenters
do stuff
# Connect to vCenter server # Connect-VIServer -Server <vCenterServer> -User <Username> -Password <Password> # Specify the cluster name $clusterName = "YourClusterName" # Get all virtual machines on the specified cluster $vmList = Get-VM -Location (Get-Cluster -Name $clusterName) # Display information about each virtual machine foreach ($vm in $vmList) { Write-Host "VM Name: $($vm.Name) | Cluster: $($vm.Cluster) | PowerState: $($vm.PowerState)" } # Disconnect from vCenter server Disconnect-VIServer -Confirm:$false