Thank you for your input, I really appreciate it. My goal is to find multiple advanced settings related to a hardening guide. I tested like you did and see a huge difference in speed between the two command configurations.
Original Message:
Sent: Mar 07, 2025 11:23 AM
From: RThornburg
Subject: get-advancedsetting with entity
James are you just trying to find VM's where isolation.device.connectable.disable or isolation.tools.dnd.disable is not true. ie for STIG's V-258710 and V-258704?
But to answer your question, in my environment moving the "Where {$_.name -match $Settings}" before the select sped up the look up significantly.
$AdvancedSettings = $Cluster | Get-VM | Get-AdvancedSetting | Where {$_.name -match $Settings}| Select name,value,entity
But you could also do a specific check vs pulling in all AdvancedSettings and then filtering like:
$AdvancedSettings_connectabledisable = $Cluster | Get-vm | where {(Get-AdvancedSetting -Entity $_ -Name isolation.device.connectable.disable).value -ne $true} | Select name
$AdvancedSettings_toolsdnddisable = $Cluster | Get-vm | where {(Get-AdvancedSetting -Entity $_ -Name isolation.tools.dnd.disable).value -ne $true}| Select name
Original Message:
Sent: Mar 06, 2025 07:10 PM
From: James Dougherty
Subject: get-advancedsetting with entity
Hi,
Are there any suggestions to speed up Get-AdvancedSetting for a list of virtual machines? When adding entity, Get-AdvancedSetting slows down quite a bit. All I'm trying to do is reference the VM name with a large Get-AdvancedSettings variable.
My example -
$Settings = "isolation.device.connectable.disable|isolation.tools.dnd.disable"
$AdvancedSettings = $Cluster | Get-VM | get-AdvancedSetting | Select name,value,entity | Where {$_.name -match $Settings}
$Cluster is the current cluster in a foreach loop.