This is what I did to get it to work. Does what it is supposed to as far as I can tell..
$csv=Import-Csv-Path"e:\scripts\hunter\vantage_prod.csv"
foreach ($entin ($csv))
{
$ds=Get-Datastore"DST_PROD_OS_HUS127*" | sortFreeSpaceGB-Descending | Select-Object-First 1
Foreach ($HardDiskin (Get-VM-Name$ent.vmnames | Get-HardDisk))
{
$vm=Get-VM-Name$ent.vmnames
$hds=Get-HardDisk-VM$vm
$lunname=Get-VM-Name$ent.vmnames | Get-HardDisk | Select-Object-Property @{N="Datastore";E={$HardDisk.FileName.Split("]")[0].TrimStart("[")}}
If ($lunname-like"*DM_PROD_OS_VSP986*"){Get-VM-Name$ent.vmnames | Get-HardDisk | Move-HardDisk-Datastore$ds-Confirm:$false}
else{Write-Host$ent.vmnames' not migrated'}
}
}
What is a better way to do this?