Quantcast
Viewing all articles
Browse latest Browse all 180923

clean up my html

OK Here is my delema...

 

I stink at POWERCLI and I stink at HTML... it is a 50/50 which is worse...

 

What im trying to do is make the following code output to HTML in table format.... Basically eye candy for MGMT. They look at the html I created from just running the following and tell me...serious!!!

 

Get-Cluster CLUSTER01, CLUSTER02 |
Get-VM  | Get-Snapshot | Select VM,Name,Description,@{N="SizeGB";E={[math]::Round($_.SizeGB,0
)}}  |
ConvertTo-HTML | Out-File C:\temp\Scripts\SSize.html

 

 

 

What I would prefer is if there was a way to place it tables with borders... If anyone has any ideas that would be great.

 

 

 

 

NOW...

 

I was tinkering with this code, I can get the tables to work populate but it seems to work when gathering info like the following. I have other scripts that utilize the format below mainly to gather info on vm's..

 

I  frankly can not figure out how to do what I want for snaphots in the example below..(placing the code I need in the LARGER font bolded area below.)

I prefer an easy way like the very top code, but beggers can not be choser Image may be NSFW.
Clik here to view.

 

 

$HTML = "yes"
$FileHTML = New-Item -type file "E:\Scripts\vm-info\VMInfo_$datefile.html"
Function Create-HTMLTable
{
param([array]$Array)
$arrHTML = $Array | ConvertTo-Html
$arrHTML[-1] = $arrHTML[-1].ToString().Replace(‘</body></html>’,"")
Return $arrHTML[5..2000]
}

 

$output = @()
$output += ‘<html><head></head><body>’
$output +=
‘<style>table{border-style:solid;border-width:1px;font-size:8pt;background-color:#ccc;width:100%;}th{text-align:left;}td{background-color:#fff;width:20%;border-style:so
lid;border-width:1px;}body{font-family:verdana;font-size:12pt;}h1{font-size:12pt;}h2{font-size:10pt;}</style>’

 

 

 

#$Report = @()
$Report=New-Object -TypeName system.collections.arraylist

 


foreach ($vm in Get-VM -Name MYVM | where {$_.Guest -like "*Linux*"})

 

{
$reportedvm= "" | Select-Object VirtualMachineName
$reportedvm.VirtualMachineName=$vm.name

$report.add($reportedvm)|out-null
}

 

 

 

if ($HTML -eq "yes") {
$output += ‘<p>’
$output += ‘<p>’
$output += Create-HTMLTable $report
$output += ‘</p>’
$output += ‘</body></html>’
$output | Add-Content $FileHTML }


Viewing all articles
Browse latest Browse all 180923

Trending Articles