Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. $TargetCluster = "Cluster-Name"
  2. $TargetGroup = "VM-Group-Name"
  3.  
  4. $VcSv = "vcenter.vsphere.local"
  5. $VcUser = "administrator@vsphere.local"
  6. $VcPass = "password"
  7.  
  8. Import-Module VMware.PowerCLI
  9.  
  10. Connect-VIServer -Server $VcSv -User $VcUser -Password $VcPass
  11. $PowerOnVms = Get-VM | Where-Object { $_.PowerState -eq "PoweredOn" }
  12. Foreach ($TargetVm in $PowerOnVms) {
  13. if ($TargetVm.GuestID -match "windows.*") {
  14. Get-Cluster -Name $TargetCluster | Get-DrsClusterGroup -Name $TargetGroup | Set-DrsClusterGroup -VM $TargetVm -Add
  15. }
  16. }
  17.  
  18. Disconnect-VIServer -Server $VcSv -Confirm:$False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement