filter Get-VMConfigurationParameter ( [string]$Key ) { if ( $_ -isnot [VMware.VimAutomation.Client20.VirtualMachineImpl] ) { Write-Warning "Expected virtual machine object on pipeline, skipping $_" continue } $vmView = $_ | Get-View if ( $Key ) { $Output = $vmView.Config.ExtraConfig | Where-Object { $_.Key -like $Key } } else { $Output = Write-Output $vmView.Config.ExtraConfig } if ( $Output ) { # This removes a couple of unneeded values and adds a new one $Output = $Output | Select-Object -property VM, Key, Value $Output.VM = $_ } Write-Output $Output } filter Set-VMConfigurationParameter { param ( [string]$Key, [string]$Value, [switch]$RunAsync = $false ) if ( $_ -isnot [VMware.VimAutomation.Client20.VirtualMachineImpl] ) { Write-Warning "Expected virtual machine object on pipeline, skipping $_" continue } if ( !$Key ) { $Key = Read-Host "Key" } if ( !$Value ) { $Value = Read-Host "Value" } $vmView = $_ | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.ExtraConfig += New-Object VMware.Vim.OptionValue $vmConfigSpec.ExtraConfig[0].Key = $Key $vmConfigSpec.ExtraConfig[0].Value = $Value if ( $RunAsync ) { $vmView.ReconfigVM_Task( $vmConfigSpec ) } else { $vmView.ReconfigVM( $vmConfigSpec ) } }