New-HTML
Building block for creating HTML elements. A starting point for all other cmdlets in PSWriteHTML except Out-HtmlView.
Syntax
New-HTML [-AddComment] [-Author <String>] [-AutoRefresh <Int32>] [-DateFormat <String>] [-Encoding <Object>] [-FavIcon <Uri>] [-FilePath <String>] [-Format] [[-HtmlData] <ScriptBlock>] [-Language <String>] [-Minify] [-Online] [-ShowHTML] [-Temporary] [-TitleText <String>] [-UseCssLinks] [-UseJavaScriptLinks] [<CommonParameters>]#All Parameter SetsExamples
EXAMPLE 1
New-HTML {
New-HTMLSection -HeaderText 'Donut Charts - Defaults' -CanCollapse {
New-HTMLPanel {
New-HTMLChart {
New-ChartToolbar -Download
#New-ChartBarOptions -Gradient
New-ChartLegend -Name 'Time', 'Money', 'Taxes', 'test'
New-ChartBar -Name 'Test' -Value 1, 2, 3, 0
New-ChartBar -Name 'Test1' -Value 2, 5, 7, 0
New-ChartBar -Name 'Test2' -Value 3, 1, 50, 5
}
}
New-HTMLPanel {
New-HTMLChart {
New-ChartToolbar -Download
#New-ChartBarOptions -Gradient
New-ChartLegend -Name 'Time', 'Money', 'Taxes' -Color Red, Yellow, Green
New-ChartBar -Name 'Test' -Value 1, 2, 3
New-ChartBar -Name 'Test1' -Value 2, 5, 7
New-ChartBar -Name 'Test2' -Value 3, 1, 2
}
}
New-HTMLPanel {
New-HTMLChart {
New-ChartToolbar -Download
New-ChartBarOptions -Type barStacked
New-ChartLegend -Name 'Time', 'Money', 'Taxes' -Color Red, Yellow, Green
New-ChartBar -Name 'Test' -Value 1, 2, 3
New-ChartBar -Name 'Test1' -Value 2, 5, 7
New-ChartBar -Name 'Test2' -Value 3, 1, 2
}
}
}
} -ShowHTML -FilePath $PSScriptRoot\Example-ChartBarNext.html -Online -FormatEXAMPLE 2
New-HTML -TitleText "Testing HideButtons" -Online -FilePath "$PSScriptRoot\Example7_06.html" {
# Hide Buttons
New-HTMLSection -HeaderText "Hide Buttons" -Content {
New-HTMLTable -DataTable $Table -HideButtons
}
New-HTMLSection -Invisible {
New-HTMLSection -HeaderText "Hide Buttons" -Content {
New-HTMLTable -DataTable $Table -HideButtons -Transpose
}
New-HTMLSection -HeaderText 'Some chart' {
New-HTMLChart {
New-ChartPie -Name 'Passed' -Value 5 -Color $ColorPassed
New-ChartPie -Name 'Failed' -Value 10 -Color $ColorFailed
New-ChartPie -Name 'Skipped' -Value 15 -Color $ColorSkipped
}
}
}
New-HTMLSection -HeaderText "Code used to generate above tables" -Content {
New-HTMLCodeBlock {
New-HTMLSection -HeaderText "Hide Buttons" -Content {
New-HTMLTable -DataTable $Table -HideButtons
}New-HTMLSection -Invisible { New-HTMLSection -HeaderText "Hide Buttons" -Content { New-HTMLTable -DataTable $Table -HideButtons -Transpose } New-HTMLSection -HeaderText 'Some chart' { New-HTMLChart { New-ChartPie -Name 'Passed' -Value 5 -Color $ColorPassed New-ChartPie -Name 'Failed' -Value 10 -Color $ColorFailed New-ChartPie -Name 'Skipped' -Value 15 -Color $ColorSkipped } } } } } } -ShowHTML
Parameters
- -AddComment SwitchParameter
- Adds additional commands to the generated HTML file. This is useful for tracking or knowing what is what.
- Defines the author information in the HTML file (meta information). If not specified, the author information is skipped.
- -AutoRefresh Int32
- Defines if the page should be refreshed automatically every X seconds.
- -DateFormat String
- Defines the date format in the HTML file (meta information). Default is 'yyyy-MM-dd HH:mm:ss'
- -Encoding Object
- Provides ability to choose encoding of the HTML file. Not really required to use, as UTF8 is the default. Options available: 'Unknown', 'String', 'Unicode', 'Byte', 'BigEndianUnicode', 'UTF8', 'UTF7', 'UTF32', 'Ascii', 'Default', 'Oem', 'BigEndianUTF32'
- Possible values:
Unknown,String,Unicode,Byte,BigEndianUnicode,UTF8,UTF7,UTF32,Ascii,Default,Oem,BigEndianUTF32 - -FavIcon Uri
- Provides ability to add a favicon to the HTML page. Can be a link or file path
- -FilePath String
- Provides the path to the file to be created.
- -Format SwitchParameter
- Formats HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
- -HtmlData ScriptBlock
- Provides ability to specify one or more elements within HTML. Using New-HTML without it, makes no larger sense.
- -Language String
- -Minify SwitchParameter
- Minifies HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
- -Online SwitchParameter
- Enables or Disables linking of CSS/JS. When Online is enabled that means that the CSS/JS files are loaded from the CDN. When Online is disabled that means that the CSS/JS files are all loaded from same HTML file (making it very large).
- -ShowHTML SwitchParameter
- Opens HTML in browser when generating of HTML is done. When no filepath is provided it uses temporary path instead. Good for testing.
- -Temporary SwitchParameter
- Forces use of temporary file name. Doesn't work with -FilePath parameter.
- -TitleText String
- Title of the HTML page
- -UseCssLinks SwitchParameter
- Deprecated - will be removed
- -UseJavaScriptLinks SwitchParameter
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.