Hi, I have a script that loops through all the VM’s on a specific host and checks the ‘isolation.tools.copy.disable’. I am trying to get the code so that if any one VM shows that the setting is $False (users can copy to the console) it saves a value of “Non-Compliant” into a variable. My problem what ever the last server in the loops results are in what ends up in the variable.
Here is my code:
#Connects directly to the VMHost
Connect-VIServer $vmhost -Credential $Credential
#Gets all the VMs on a VMHost
$HostVMs = $vmhost | Get-VM *
$VMSettings =$null
$VMSettings += ForEach ($HostVM in $HostVMs)
{
#Get the VM Copy setting
$ConsoleCopyCompliance = "Compliant"
$VMConsoleCopySettings = $null
$VMConsoleCopySettings = {$HostVM | Get-AdvancedSetting -Name "isolation.tools.copy.disable" | Select Entity, Name, Value}
If($VMConsoleCopySetting.Value -eq $False) {$ConsoleCopyCompliance = "Non-Compliant"}
$ConsoleCopyVMs = $VMConsoleCopySettings | where {$_.value –eq “false”}
#$ConsoleCopyVMs | Select Entity,Value | ft
$ConsoleCopyCompliance
All help is appreciated. Thanks , Ed