lElOUCHE_79
Enthusiast
Enthusiast

Check - Activate & Set AdvansedSettings for VM

Jump to solution

I have the below script to check a specific AdvancedSetting for VMs, I will need assistance to set the parametre to True by cluster

$AdvancedSetting = "isolation.tools.autoInstall.disable"
Get-VM | `
Select Name, @{Name="autoInstall"; Expression={
#Start "Expression
if ( ($_ | Get-AdvancedSetting -Name $AdvancedSetting).Value -eq "true") {
"Disabled"
} else {
#Start "Is it enabled or blank?"
if ($_ | Get-AdvancedSetting -Name $AdvancedSetting) {
"Enabled"
}
else {
"Setting Doesn't Exist"
}
#End "Is it enabled or blank?"
}
#End "Expression"
}
#End "DiskShrink Hashtable"
} | export-csv -notypeinformation -path .\isolation_tools_autoInstall_disable-Details.csv

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You could do something like this

$AdvancedSetting = "isolation.tools.autoInstall.disable"
$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName | Get-VM -PipelineVariable vm |
ForEach-Object -Process {
    $setting = Get-AdvancedSetting -Entity $vm -Name $AdvancedSetting
    if(-not $setting){
        New-AdvancedSetting -Entity $vm -Name $AdvancedSetting -Value 'true' -Confirm:$false
    }
    else{
        if($setting.Value -ne 'true'){
            Set-AdvancedSetting -AdvancedSetting $setting -Value 'true' -Confirm:$false
        }
    }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership

You could do something like this

$AdvancedSetting = "isolation.tools.autoInstall.disable"
$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName | Get-VM -PipelineVariable vm |
ForEach-Object -Process {
    $setting = Get-AdvancedSetting -Entity $vm -Name $AdvancedSetting
    if(-not $setting){
        New-AdvancedSetting -Entity $vm -Name $AdvancedSetting -Value 'true' -Confirm:$false
    }
    else{
        if($setting.Value -ne 'true'){
            Set-AdvancedSetting -AdvancedSetting $setting -Value 'true' -Confirm:$false
        }
    }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

lElOUCHE_79
Enthusiast
Enthusiast

Thank you is working fine 🙂 

0 Kudos