Skip to content

Latest commit

 

History

History
312 lines (253 loc) · 5.87 KB

File metadata and controls

312 lines (253 loc) · 5.87 KB
external help file PSWebGui-help.xml
Module Name PSWebGui
online version
schema 2.0.0

Format-Html

SYNOPSIS

Formats and stylizes PowerShell commands output using HTML and Bootstrap.

SYNTAX

Table (Default)

Format-Html [-InputObject] <PSObject> [-Darktable] [-Darkheader] [-Striped] [-Hover] [-Id <String>] [-Class <array>] [<CommonParameters>]

Cards

Format-Html [-InputObject] <PSObject> -Cards <Int32> [-Id <String>] [-Class <array>] [<CommonParameters>]

Raw

Format-Html [-InputObject] <PSObject> [-Raw] [<CommonParameters>]

DESCRIPTION

Converts the output of PowerShell commands, passed by pipeline, to HTML format and adds Bootstrap style classes.

Depending on the set of parameters, the output can be converted to table format, card format, or raw (no style). If no parameters are set, by default it is converted to table format.

In essence, it is like ConverTo-Html -Fragment PowerShell cmdlet but with Bootstrap styling built-in and another features.

EXAMPLES

EXAMPLE 1

PS> Get-Service | Format-Html

<table class='table'>
<thead>
<tr>
<th>Name</th>
<th>RequiredServices</th>
<th>CanPauseAndContinue</th>
...
</tr>
</thead>
<tbody>
<tr>
<td>AJRouter</td>
<td>System.ServiceProcess.ServiceController[]</td>
<td>False</td>
...
</tr>
<tr>
<td>ALG</td>
<td>System.ServiceProcess.ServiceController[]</td>
<td>False</td>
...
</tr>
...
</tbody>
</table>

EXAMPLE 2

PS> Get-Process | Select-Object Cpu, Name | Format-Html -Darkheader -Striped -Hover -Id "myTable" -Class "myClass","yourClass"


<table class='table table-striped table-hover myClass yourClass' id='myTable'>
<thead class='thead-dark'>
<tr>
<th>CPU</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1475,09375</td>
<td>msedge.exe</td>
</tr>
<tr>
<td>0,671875</td>
<td>explorer.exe</td>
</tr>
...
</tbody>
</table>

EXAMPLE 3

PS> Get-Service | Select-Object Status, DisplayName | Format-Html -Cards 3

<div class='row row-cols-3'>
<div class='col mb-1'>
<div class='card h-100'>
<div class='card-body'>
<h5 class='card-title'>Stopped</h5>
<p class='card-text'>AJRouter</p>
</div>
</div>
</div>
<div class='col mb-1'>
<div class='card h-100'>
<div class='card-body'>
<h5 class='card-title'>Running</h5>
<p class='card-text'>ALG</p>
</div>
</div>
</div>
...
</div>

EXAMPLE 4

PS> Get-Date | Format-Html -Raw

Tuesday, June 25, 2019 14:53:32

PARAMETERS

-InputObject

Command or object to be formated in HTML, passed by pipeline.

Type: PSObject
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Darktable

Set this parameter to display a dark table.

<table class="table table-dark">...</table>
Type: SwitchParameter
Parameter Sets: Table
Aliases: Tabledark, Table-dark

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Darkheader

Set this parameter to display a table with dark header.

<table class="table">
    <thead class="thead-dark">...</thead>
</table>
Type: SwitchParameter
Parameter Sets: Table
Aliases: Theaddark, Thead-dark

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Striped

Set this parameter to display a striped table.

<table class="table table-striped">...</table>
Type: SwitchParameter
Parameter Sets: Table
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Hover

Set this parameter to display a hoverable rows table.

<table class="table table-hover">...</table>
Type: SwitchParameter
Parameter Sets: Table
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Id

Use this parameter to set an id attribute.

<table id="table1">...</table>
Type: String
Parameter Sets: Cards, Table
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Cards

Specifies a number, between 1 and 6, to display the command output in Bootstrap card style. The number specified is the number of cards displayed per row.

This parameter only displays the first two properties of the object passed. The first one will be dipslayed as the card title, the second will be the card text. (See the cards section of the Bootstrap v4.6 documentation for more info about card layout)

Type: Int32
Parameter Sets: Cards
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Class

Use this parameter to set an array of classes for the table or cards.

<table clas="table myClass">...</table>
<div class="row-cols-3 myClass" >...</div>
Type: Array
Parameter Sets: Cards, Table
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Raw

Set this parameter to display output in HTML format but without style.

Type: SwitchParameter
Parameter Sets: Raw
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

System.Object

OUTPUTS

System.String

NOTES

RELATED LINKS