VMware Cloud Community
CarlosDionizio
Contributor
Contributor
Jump to solution

Getting information about Guest in table

Hi Dear! I'm using this:

Get-VM | Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_ | Get-Datastore}}

Output:

Name : pvmlxxxx
VMHost: php00xxxr
NumCpu: 2

PowerState : PoweredOn

MemoryMB   : 8192

Datastore  : VNXSxx

I need this output in .HTML:

Name|VMHost|NumCpu|PowerState|MemoryMB/GB|Datastore

Any can help me about this?

Tks Carlos

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try this

Get-VM | Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_ | Get-Datastore}} | ConvertTo-HTML | Out-File report.html

You can of course produce much elaborate HTML output by using parameters on the ConvertTo-Html cmdlet, and by using style sheets (CSS).

See for example Using the ConvertTo-Html Cmdlet


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Try this

Get-VM | Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_ | Get-Datastore}} | ConvertTo-HTML | Out-File report.html

You can of course produce much elaborate HTML output by using parameters on the ConvertTo-Html cmdlet, and by using style sheets (CSS).

See for example Using the ConvertTo-Html Cmdlet


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

CarlosDionizio
Contributor
Contributor
Jump to solution

LucD escreveu:

Try this

Get-VM | Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_ | Get-Datastore}} | ConvertTo-HTML | Out-File report.html

You can of course produce much elaborate HTML output by using parameters on the ConvertTo-Html cmdlet, and by using style sheets (CSS).

See for example Using the ConvertTo-Html Cmdlet

Hi LucD

Tks! For your help!!

I try this in my profile

#### config  HTML ###############################

$aforma = "<style>"

$aforma = $aforma + "BODY{background-color:peachpuff;}"

$aforma = $aforma + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"

$aforma = $aforma + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"

$aforma = $aforma + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"

$aforma = $aforma + "</style>"

##### End config ##################################

And script line:

Get-VM | Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_| sort-object -property Name | Get-Datastore}} | ConvertTo-HTML -head $aforma| Out-File report_$DATTA.html

Its a simple script but....Smiley Happy

Sorry my bad english im brazilian!! :smileylaugh:

Reply
0 Kudos