Yes now its copying and changing vmx version as expected but it is only taking one vm in the loop.
For example if i give as below its just changing for this VM 'SEP00VVM-278 (90389be9-cc74-49e5-aa8a-3079efea166d)' 3 times. Is there anything wrongly mentioned in the loop.
what is $t its no where mentioned in the script.
foreach ($vmName in (Get-VM 'SEP00VVM-278 (90389be9-cc74-49e5-aa8a-3079efea166d)','POSSoulFoods (868a2a98-9509-4646-b396-6b8093101f81)','AV_SCM_3 - wusas230233-003 (d7ef0854-c5f3-4ad9-aedf-2ddc70d6b36e)')) {
$tgtFolder = $env:Temp
Get-VM -Name $vmName.name | % {
$dsName, $vmxPath = $_.ExtensionData.Config.Files.VmPathName.Split()
$dsName = $t.Split(']').TrimStart('[')[0]
$vmxPath = $t.Split(']')[1].TrimStart(' ')
$vmxName = $vmxPath.Split('/')[-1]
$vmxFolder = [string]::Join('/', ($vmxPath.Split('/')[-99..-2]))
$ds = Get-Datastore -Name $dsName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root "\" | Out-Null
Copy-DatastoreItem -Item "DS:$vmxPath" -Destination $tgtFolder
(Get-Content -Path "$tgtFolder\$vmxName")| ForEach-Object {$_ -Replace 'virtualHW.version = "11"', 'virtualHW.version = "10"'} | Set-Content -Path "$tgtFolder\$vmxName"
Copy-DatastoreItem -Item "$tgtFolder\$vmxName" -Destination "DS:$vmxFolder" -Force
Get-ChildItem -Path "$tgtFolder\$vmxName" | Remove-Item -Confirm:$false
Remove-PSDrive -Name DS -Confirm:$false
}
}