Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

Help with datastore migration script

$
0
0

Hey Everyone,

 

I am currently tasked with migrating disks to new storage. Each VM could have multiple disks on different datastores. The script I am working on will check the VM for disks located on a certain datastore, then if needed migrate the disk(s) to the new datastore. I am lost though. I hope I am at least on the right path. Any help is much appreciated.

 

Thanks!

 

$csv = Import-Csv -Path "e:\scripts\hunter\vantage_qadev.csv"

 

 

 

 

 

 

foreach ($ent in ($csv))

  {

  $ds = Get-Datastore "QADEV_OS_HUS127*" | sort FreeSpaceGB -Descending | Select-Object -First 1

  $vmname = Get-VM -Name $ent.vmnames

  $vmds = $vmname | Get-HardDisk | Select Filename

 

  If ($vmds -eq "*QADEVOS_VSP986*"){Get-VM $ent.vmnames | Get-HardDisk | Move-HardDisk -Datastore $ds}

  Else {Write-Host "Migration not needed"}

  }


Viewing all articles
Browse latest Browse all 176483

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>