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

New-HTMLAnchor

Module PSWriteHTML

Creates a new HTML anchor element.

Syntax

New-HTMLAnchor [[-Class] <String>] [[-HrefLink] <String>] [[-Id] <String>] [[-Name] <String>] [[-OnClick] <String>] [[-Style] <IDictionary>] [[-Target] <String>] [[-Text] <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

This function creates a new HTML anchor element (<a>) with specified attributes.

Examples

Authored help example

EXAMPLE 1

New-HTMLAnchor -Target _parent
Creates an anchor element with the target attribute set to "_parent".

New-HTMLAnchor -Id "show_$RandomNumber" -Href '#' -OnClick "show('$RandomNumber');" -Style "color: #ffffff; display:none;" -Text 'Show' Creates an anchor element with specified attributes and text.

Output: <a id="show_$RandomNumber" class="" target="_parent" href="#" onclick="show('$RandomNumber');" style="color: #ffffff; display:none;">Show</a>

Parameters

-Class String optionalposition: 3
The CSS class of the anchor element.
The URL of the linked document.
-Id String optionalposition: 1
The ID of the anchor element.
-Name String optionalposition: 0aliases: AnchorName
The name of the anchor element.
-OnClick String optionalposition: 5
JavaScript code to execute when the anchor element is clicked.
-Style IDictionary optionalposition: 6
The CSS styles to apply to the anchor element.
-Target String optionalposition: 2
Specifies where to open the linked document.
-Text String optionalposition: 7aliases: AnchorText, Value
The text to display within the anchor element.

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.