Ok, I think I understood what you are trying to do.
I took that code and changed it slightly.
Have a look and feel free to ask if some parts are not clear.
$vcenter = '192.168.0.1'
Connect-VIServer -Server $vcenter
$vpx = Get-View -Id 'OptionManager-VpxSettings'
$rowCount = $vpx.Setting.Count
$colNames = $vpx.Setting | Select -First 1 | Get-Member -MemberType Property |
where {$_.Name -notmatch "^Dynamic"} | Select -ExpandProperty Name
$colCount = $colNames.Count
$msWord = New-Object -ComObject Word.Application
$wordDoc = $msWord.Documents.Add()
$msWord.Visible = $true
$wordDoc.Activate()
$doctable = $wordDoc.Tables.Add($wordDoc.Application.Selection.Range,$rowCount + 1,$colCount)
# Header
for($col = 0; $col -lt $colCount; $col++){
$cell = $doctable.cell(1,$col + 1).Range
$cell.font.bold = $true
$cell.InsertAfter($colNames[$col])
}
# Data
for($row = 0; $row -lt $rowCount; $row++){
for($col = 0; $col -lt $colCount; $col++){
$cell = $doctable.cell($row + 2,$col + 1).Range
$cell.font.bold = $true
$cell.InsertAfter($vpx.Setting[$row].$($colNames[$col]))
}
}
#Table formatting stuff
$doctable.columns.autofit()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That works; however I don't understand how you are telling it to pull just 2 of the values because I see 3 (Key, Value, Summary) in vCenter Advanced Setting. Some items don't have all 3 and that is fine. But would like to include the summary if possible.
Script is a lot more clearner than my attempt at pasting info from different scripts over the internet.
Thanks again
Is that on 5.1 vSphere server that you see the third property ?
I'll check.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Correct it is 5.1
Have a follow up question.
I have mulitple vcenters and want to pull the data, however the $vpx = Get-View id 'OptionManager-VpxSettings' only seem work with 1 venter at a time.
Here is what I have
$vc1 = 192.168.0.1
$vc2 = 192.168.0.2
$vcenter = connect-viserver $vc1 $vc2
foreach ($vc in $vcenter)
{
$vpx = Get-View -Id 'OptionManager-VpxSettings'
....same stuff
}
It work if I put only 1 vcenter in at a time, but that defeats my purpose.
You will have to use the Server parameter, like this
$vpx = Get-View -Id 'OptionManager-VpxSettings' -Server $vc
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is cool !
thanks Luc