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.
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.
$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"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
$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"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference