Automation

 View Only
  • 1.  Retrieving Advance Setting of Virtual Machine

    Posted Jul 12, 2020 04:38 AM

    I am trying to fetch advance configuration using this. Am I doing any error? Sometimes it is not showing blank CSV.

    Add-PSSnapin "VMware.VimAutomation.Core"

    Connect-VIServer vc1, vc2, vc3

    $SettingName = 'svga.vgaOnly'

    $date=get-Date -format "ddMMyy_HHmm"

    Get-VM | Get-AdvancedSetting -Name $SettingName | Select Entity, Name, Value | ft -Autosize | Export-csv "SVGA_$date.csv"

    -----------

    Another point, how can we add vCenter name in csv output. It's generating only VM name, not vcenter. As I am retrieving for multiple vcenters, so need to filter out.

    Get-VM | Get-AdvancedSetting -Name $SettingName | Select Entity, Name, Value

    CSV Format is also not showing in columns, rather it is fetching all information only in one column and it needs manual work to format the output.



  • 2.  RE: Retrieving Advance Setting of Virtual Machine
    Best Answer

    Posted Jul 12, 2020 07:16 AM

    Are you using such an old PowerCLI version that you need the Add-PSSnapin line?

    The vCenter can be added with a calculated property.

    The misinformed CSV is due to the Format-Table that you have in there.

    Connect-VIServer vc1, vc2, vc3

    $SettingName = 'svga.vgaOnly'

    $date=get-Date -format "ddMMyy_HHmm"

    Get-VM |

    Get-AdvancedSetting -Name $SettingName |

    Select Entity, Name, Value, @{N='vCenter';E={([uri]$_.Entity.ExtensionData.Client.ServiceUrl).Host}} |

    Export-csv "SVGA_$date.csv"