Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

Stars 1,019
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.41.0
Language: PowerShell Updated: 2026-10-03
Command

Save-HTML

Module PSWriteHTML

Saves HTML (text) to a file. Can be used with conjucncton with New-HTML.

Syntax

Save-HTML [[-Encoding] <Object>] [[-FilePath] <String>] [-Format] [-HTML] <String> [-Minify] [-ShowHTML] [[-Suppress] <Boolean>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Saves HTML (text) to a file. Can be used with conjucncton with New-HTML, although New-HTML has Save-HTML built-in already when providing FilePath parameter.

Examples

Authored help example

EXAMPLE 1

$Company = 'Evotec'

$Text = @" This email is from Evotec. It may contain confidential information. It is intended for the addressee only and may not be copied or disclosed to any third party without our permission. If you are not the intended recipient please contact the sender as soon as possible and delete the material from any computer. If this email has been sent as a personal message to the addressee, the sender is not acting in his/her capacity as an employee or officer of $Company Limited and no liability is accepted for the content of any such email. Outgoing email may be monitored for the purpose of ensuring compliance with our email policy and relevant laws "@

$HTML = New-HTMLText -FontSize 10 -FontFamily 'Source Sans Pro' -Text $Text Save-HTML -FilePath $PSScriptRoot\Disclaimer.html -HTML $HTML -ShowHTML

EXAMPLE 2

$Test = EmailBody {
    EmailText -LineBreak
    EmailText -Text 'Z poważaniem' -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray -LineBreak
    EmailText -Text $DisplayName -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -Text $Title -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -Text $Department -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -LineBreak
    if ($Mobile) {
        EmailText -Text "m: $Mobile" -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    }
    EmailText -Text "e: $Email" -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -LineBreak
    EmailText -Text $CompanyName -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -Text $StreetAddress -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -Text "$PostalCode $City" -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -LineBreak
    EmailText -Text "[www.aliorleasing.pl](https://www.aliorleasing.pl)" -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray
    EmailText -LineBreak
    EmailLayoutRow {
        EmailLayoutColumn {
            EmailImage -Source 'https://aliorleasing.pl/images/logoAL2.jpg' -UrlLink '' -AlternativeText 'Alior Leasing Logo' -Width '134' -Inline -Height '90'
        }
        EmailLayoutColumn {

} EmailLayoutColumn { EmailImage -Source 'https://aliorleasing.pl/images/akcia-nnw.jpg' -UrlLink '' -AlternativeText 'Alior Leasing Logo' -Width '300' -Inline -Height '90' } } EmailText -LineBreak EmailText -FontWeight bold, normal -FontSize 8pt -FontFamily 'Verdana,sans-serif' -Color Gray -Text "Alior Leasing", ` " Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. Łopuszańska 38D, 02-232 Warszawa, wpisana do rejestru przedsiębiorców Krajowego Rejestru Sądowego pod numerem KRS: 0000554171, której dokumentacja przechowywana jest w Sądzie Rejonowym dla M. St. Warszawy w Warszawie, XIV Wydział Gospodarczy Krajowego Rejestru Sądowego, NIP: 5223027866, REGON: 361335353, o kapitale zakładowym i wpłaconym: 15 009 000,00 PLN." EmailText -LineBreak }

Save-HTML -FilePath $PSScriptRoot\Output\TestBody2.html -ShowHTML -HTML $Test

Parameters

-Encoding Object optionalposition: 2
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
-FilePath String optionalposition: 0
Provides the path to the file to be created.
-Format SwitchParameter optional
Formats HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
-HTML String requiredposition: 1
HTML (text) to be saved.
-Minify SwitchParameter optional
Minifies HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
-ShowHTML SwitchParameter optionalaliases: Open, Show
Opens HTML in browser when generating of HTML is done. When no filepath is provided it uses temporary path instead. Good for testing.
-Suppress Boolean optionalposition: 3aliases: Supress
If Suppress is used then no output is shown. If Suppress is set to false then FilePath is returned.

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.