Automation

 View Only
  • 1.  listing configuration parameters of a virtual machine

    Posted May 16, 2012 03:33 PM

    I would like to be able to retrieve the list of configuration parameters of a virtual machine, specifically the ones under Options > Advanced > General > Configuration Parameters when you go to edit settings of a virtual machine.  I found this article in the powershell community - http://communities.vmware.com/docs/DOC-18653 (Retrieve and Set VM Advanced Configuration (VMX) settings).  I run the script according to the example by first connecting to vCenter with the vSphere PowerCLI and then executing Get-VM vm-name | Get-VMAdvancedConfiguration.  It appears to run and gives not errors, but returns nothing.  I know that this virtual machine has settings under the Configuration Parameters also so I know it's either not the script I'm looking for or I'm doing something wrong.  Is there a way to retrieve this information via powershell.  I would like to provide this information to auditors.



  • 2.  RE: listing configuration parameters of a virtual machine

    Posted May 16, 2012 04:00 PM

    That function sets advanced configuration parameters.

    To retrieve advanced configuration parameters you can do

    (Get-VM -Name vm-name).ExtensionData.Config.ExtraConfig


  • 3.  RE: listing configuration parameters of a virtual machine

    Posted May 18, 2012 09:21 PM

    I'm trying to return a list of configuration parameters for some vm's in a specific cluster.  So here is what I've done:

    $vms = Get-VM -Location ClusterName | Select-Object -Property Name

    foreach ($vm in $vms)

    {Get-VM -Name $vm).ExtensionData.Config.ExtraConfig}

    There is a problem with this because the result from the first line returns the column name along with the list off all the machines in the cluster so the variable of $vm looks like the following:

    @{Name=MachineName1}

    @{Name=MachineName2}

    @{Name=MachineName3}

    Is there anyway of just providing the list of machine names without have the column name prepending to the variable?



  • 4.  RE: listing configuration parameters of a virtual machine
    Best Answer

    Posted May 18, 2012 09:55 PM

    That is caused by the Select-Object you used on the first line.

    I'm not sure how you want to display the results, but this is just one way of doing it


    $vms
    = Get-VM -Location Clustername
    foreach
    ($vm in $vms){   $vm.ExtensionData.Config.ExtraConfig |
      Select @{N="VM";E={$vm.Name}},Key,Value
    }


  • 5.  RE: listing configuration parameters of a virtual machine

    Posted May 25, 2012 06:18 PM

    Thanks for you help.  Out-File is good enough is good enough for displaying it for me.



  • 6.  RE: listing configuration parameters of a virtual machine

    Posted May 25, 2012 08:50 PM

    Here is how I solved that, roughly similar. This allowed me, with the final variable, the ability to manipulate the data at large once all VMs had been scanned

    $GetVMs = Get-VM -Location ClusterName
    $Report=@()
    foreach ($vm in $GetVMs){
          $Report+=$vm.ExtensionData.Config.ExtraConfig |Select @{N="VM";E={$vm.Name}},@{N="Setting";E="Key"},Value
    }
    $Report

    This way when I compare it to "known good settings"... aka compare against the hardening guide I can tweak the report as needed. Basically does the same thing as Lucd though