I have a question related with the advanced settings of a VM and how to use Get-View instead of Get-VM for this particular case:
Get-VM * | Get-AdvancedSetting -Name "scsi*sharing" | Select Entity, Name, Value
My idea is to use:
Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} | Where {$_.Advanced.Setting -eq "scsi*sharing"} | Select Entity, Name, Value
but as far as I can see there is nothing for advance configuration of "VirtualMachine" here: https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.powercli.cmdletref.doc%2FVirtualMac...
I also took a look at https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.ConfigSpec.html but I cannot figure it out how to use "extraConfig" in the PowerCLI script to extract this particular information for "SCSI Sharing".
There is information how to use the API to add or change advanced key in .vmx file of a VM here: http://blogs.vmware.com/PowerCLI/2008/09/changing-vmx-fi.html but still it is not clear for me how to use this just to extract information without changing anything.
Try like this
foreach($vm in (Get-View -ViewType VirtualMachine -Property Name,Config.ExtraConfig -Filter @{'Config.Template'='False'})){
$vm.Config.ExtraConfig | where {$_.Key -like 'scsi*sharing'} |
Select @{N='VM';E={$vm.Name}},@{N='Template';E={$vm.Config.Template}},Key,Value
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
foreach($vm in (Get-View -ViewType VirtualMachine -Property Name,Config.ExtraConfig -Filter @{'Config.Template'='False'})){
$vm.Config.ExtraConfig | where {$_.Key -like 'scsi*sharing'} |
Select @{N='VM';E={$vm.Name}},@{N='Template';E={$vm.Config.Template}},Key,Value
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much, it's working as expected.
And which method wold one use to change or remove the Advanced Setting value?
You should be able to do that with the ReconfigVM method.
In the VirtualMachineConfigSpec object, that you pass as parameter to this method, there is the extraConfig property.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference