Basically, I want my script to be able to check for a particular setting, in this case "isolation.tools.copy.disable", whether it exist in each VM or not. And after checking, it would want to retrive/store the VM without the setting and add a new one. If setting exist, it would then continue and check on the existing setting value . So, here's my 'try' on achieving it however it doesn't seem to work at all. any help would be appreciated. Here the code:
#Check for console copy
Write-Host "`nCheck for Console Copy`n" -ForegroundColor Gray
$copytool = Get-VM | Get-AdvancedSetting -Name "isolation.tools.copy.disable" | Select Entity, Name, Value
$setting = Get-VM | Get-AdvancedSetting
$vmcount = (Get-VM | Measure).Count
#Check if setting exist
for ($y = 0;$y -lt $vmcount; $y++){
if ($setting[$y].Name -ne "isolation.tools.copy.disable"){
$name = $setting[$y].Entity
Write-Host "'isolation.tools.copy.disable' in $name is not Found!"
}
#check if existing setting value
else { ...... <this part is fine>