VMware Cloud Community
impranayk
Enthusiast
Enthusiast
Jump to solution

Retrieving Advance Setting of Virtual Machine

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.

-------------------------------------------------------------------------
Follow me @ www.vmwareinsight.com
Please consider marking this answer "correct" or "helpful" if you found it useful

Pranay Jha | Blog: http://vmwareinsight.com
vExpert 2016/2017, VCAP5-DCD/DCA, VCP5-DCV, VCA-Cloud, VCE-CIA, MCSE, MCITP
Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

1 Reply
LucD
Leadership
Leadership
Jump to solution

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"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference