Hi Luc,
can yu please check following code specifically orange code to get information about os type of vcenter.for some reasons i m not getting right output.
$path1 = 'D:\hc'
$path = "D:\hc\additional-$(Get-Date -Format 'yyyyMMdd-HHmm').html"
Connect-VIServer -server "vcenter1" -Credential $credentials
$head = @'
<style>
body { background-color:#dddddd;
font-family:Tahoma;
font-size:12pt; }
td, th { border:1px solid black;
border-collapse:collapse; }
th { color:white;
background-color:black; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }
</style>
'@
$fragments = @()
$vc=$global:defaultviserver
$ostype=$vc.ExtensionData.Content.about.ostype
$fragments += $ostype |
ConvertTo-Html -PreContent '<h2>ostype </h2>' |
Out-String
$embeddedorexternal=$global:DefaultVIServer |
Select Name,
@{N='PSC';E={
$pscUri = Get-AdvancedSetting -Entity $_ -Name config.vpxd.sso.admin.uri | select -ExpandProperty Value
if(([System.Uri]$_.ServiceUri).Host -eq ([System.Uri]$pscUri).Host){'Embedded'}else{'External'}
}}
$fragments += $embeddedorexternal |
ConvertTo-Html -PreContent '<h2>embeddedorexternal </h2>' |
Out-String
ConvertTo-HTML -head $head -PostContent $fragments |
Out-String | Out-File -FilePath $path
The ConvertTo-Html cmdlet expects an object, where it converts the properties to column headers and the values to entries under that column.
And you're presenting it with a string.
Try that part like this
$ostype= $vc.ExtensionData.Content.about | Select ostype
$fragments += $ostype |
ConvertTo-Html -Property ostype -PreContent '<h2>ostype </h2>' |
Out-String
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The ConvertTo-Html cmdlet expects an object, where it converts the properties to column headers and the values to entries under that column.
And you're presenting it with a string.
Try that part like this
$ostype= $vc.ExtensionData.Content.about | Select ostype
$fragments += $ostype |
ConvertTo-Html -Property ostype -PreContent '<h2>ostype </h2>' |
Out-String
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Tx I m checking.
Thanks Luc,
I changed to what you suggest to make it pscustom object.
however in second part iam not giving properties (though it is pscustom object )
$embeddedorexternal=$global:DefaultVIServer |
Select Name,
@{N='PSC';E={
$pscUri = Get-AdvancedSetting -Entity $_ -Name config.vpxd.sso.admin.uri | select -ExpandProperty Value
if(([System.Uri]$_.ServiceUri).Host -eq ([System.Uri]$pscUri).Host){'Embedded'}else{'External'}
}}
$fragments += $embeddedorexternal |
ConvertTo-Html -PreContent '<h2>embeddedorexternal </h2>' |
Out-String
Yes, I know.
I'm afraid that is a "feature" of ConvertTo-Html.
If there is only 1 property in an object, and you don't use the Property parameter, the header of that property will be shown as an *
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thnaks.