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"}
}