Evotec

Project

PSWriteHTML

PSWriteHTML is an open-source PowerShell project with packages, release history, and working documentation.

Stars 995
Forks 114
Open issues 69
PowerShell Gallery downloads 7,436,513
Release v1.41.0
Language: PowerShell Updated: 2026-04-11

API Reference

Function

Save-HTML

Namespace PSWriteHTML

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

Remarks

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

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.

Syntax

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

Parameters

Encoding Object optionalposition: 2pipeline: Falsevalues: 12
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: 0pipeline: False
Provides the path to the file to be created.
Format SwitchParameter optionalposition: namedpipeline: False
Formats HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
HTML String requiredposition: 1pipeline: False
HTML (text) to be saved.
Minify SwitchParameter optionalposition: namedpipeline: False
Minifies HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
ShowHTML SwitchParameter optionalposition: namedpipeline: Falsealiases: 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: 3pipeline: Falsealiases: Supress
If Suppress is used then no output is shown. If Suppress is set to false then FilePath is returned.