Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

You could store the settings at the start in a hash table.

And then do something like this

Connect-VIServer -Server vcenter.local -User username -Password Password

Foreach ($vm in Get-VM)

{

    $tab = @{}

    $date=Get-Date -format "ddMMyy_HHmm"

    Get-AdvancedSetting -Entity $vm | ForEach-Object -Process {

        $tab.Add($_.Name,$_.Value)

    }


    New-AdvancedSetting -Entity $vm -Name vmci0.unrestricted -Value FALSE -Confirm:$False -Force:$True

    # repeat for other settings

  

    Get-AdvancedSetting -Entity $vm |

    Select Name,@{N='OldValue';E={$tab[$_.Name]}},@{N='NewValue';E={$_.Value}} |

    Export-Csv -Path "$($vm.Name)_Settings_$($date).csv" -NoTypeInformation -UseCulture

}


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