Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # My Login Credentials
- $vi_server = "X.X.X.X" # Set to your vCenter hostname|IP
- $vcuser = "MyLogin@vsphere.local" # Set to your vCenter username to connect
- $vcpass = "VerySecurePassword123" # Set to your vCenter username password to connect
- # Connect to vCenter
- Connect-VIServer -Server $vi_server -User $vcuser -Password $vcpass
- # I want all old and new datastores as objects in arrays
- $OldDatastores = Get-Datastore TEST-01
- $NewDatastores = Get-Datastore TEST-02
- $i = 0
- # Get all VMs in each old datastore and move them
- Foreach ($OldDatastore in $OldDatastores){
- $VMs = Get-VM -Datastore $OldDatastore
- Foreach ($VM in $VMs)
- {
- # Move the VM to a new datastore
- $VM | Move-VM -Datastore $NewDatastores[$i] -RunAsync
- }
- $i++
- # Wait timer for next migrations
- Start-Sleep 5
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement