Skip to content

Instantly share code, notes, and snippets.

@Stephanevg
Created May 3, 2020 08:58
Show Gist options
  • Save Stephanevg/21d1468165a546cd40418d75d30d008c to your computer and use it in GitHub Desktop.
Save Stephanevg/21d1468165a546cd40418d75d30d008c to your computer and use it in GitHub Desktop.
Added A bootstrap 'container' class to the main div section so everything will be centralized
$HTML = html {
head {
Write-PSHTMLAsset # This simple command will add a local link to the Jquery / Chartjs and bootstrap frameworks.
# It wil allow to work with them without internet connection BUT it won't work if you send you html document per mail for example as it needs the ref to the local files.
}
body {
#The only thing I did here, is that I packted everything in a div which I added the bootstrap class 'container'
Div -Class 'Container' -Content {
#You can read on the bootstrap website more about containers -> https://getbootstrap.com/docs/4.0/layout/overview/#containers
h4 'Esta é uma lista de Processos'
hr
$Process = Get-Process | Sort-object CPU -Descending | select -first 10 # selecting the first 10 most CPU intensive process
#Preparing bootstrap classes to make our table 'pretty'
$TableClasses = "table table-bordered table-hover" #These are bootstrap classes you can assign to your html table. It will make it nice and shiny with almost no effort ;)
$TableHeaders = "thead-dark" # You can find more infos about the table classes here -> https://getbootstrap.com/docs/4.0/content/tables/
#Converting to table
ConvertTo-PSHTMLTable -Object $Process -TableClass $TableClasses -TheadClass $TableHeaders -Properties ProcessName,id,handles,cpu
#Footer message ;)
$PSHTMLlink = a {"PSHTML"} -href "https://github.com/Stephanevg/PSHTML"
h6 "Created with ❤️ using $($PSHTMLlink)"
}
}
}
#Outputing to file. (Notice I am using -Show to open the file immediatley)
Out-PSHTMLDocument -HTMLDocument $html -OutPath ./plop.html -Show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment