PowerCLI

  • 1.  get-advancedsetting with entity

    Posted 8 days ago

    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.



  • 2.  RE: get-advancedsetting with entity

    Posted 8 days ago

    Hi @James Dougherty looks like you can play with Get-View which is time faster.

    Something like:

     get-view -Server $conn -ViewType VirtualMachine -Property Name,Config.ExtraConfig -SearchRoot $yourClusterMoRef | % { $_.Config.ExtraConfig } 




  • 3.  RE: get-advancedsetting with entity

    Posted 7 days ago

    Get-view was what I was looking into after having issues but I couldn't get it working right.  However, with your example I'm able to pull exactly what I'm looking for within split seconds.  Thank you so much!!




  • 4.  RE: get-advancedsetting with entity

    Posted 8 days ago

    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




  • 5.  RE: get-advancedsetting with entity

    Posted 7 days ago

    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.