# Add-HTMLScript

Adds JavaScript content to the HTML body. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteHTML API Reference.

Project

PSWriteHTML

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

[View on GitHub](https://github.com/EvotecIT/PSWriteHTML) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteHTML/releases/tag/v1.41.0) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteHTML/1.40.0)

Stars **1,025**

Forks **114**

Open issues 

PowerShell Gallery downloads **7,576,901**

Release **v1.45.0**

Language: PowerShell Updated: 2026-11-19

Command 

**Module**

`PSWriteHTML`

Adds JavaScript content to the HTML body.

## Syntax

```
Add-HTMLScript
[-AddComments]
[[-Content] <String[]>]
[[-FilePath] <String[]>]
[[-Link] <String[]>]
[[-Placement] <Inline|Header|Footer>]
[[-ReplaceData] <IDictionary>]
[[-Resource] <IDictionary>]
[[-ResourceComment] <String>]
[-SkipTags]
[<CommonParameters>]
```

[#](#method-add-htmlscript-switchparameter-string-string-string-string-idictionary-idictionary-string-switchparameter)

Parameter set: `All Parameter Sets`

## Description

This function adds JavaScript content to the HTML body by including JavaScript code from files, strings, or links. It allows customization of the placement of JavaScript content within the HTML document.

## Examples

### Example 1

```powershell
Add-HTMLScript -Placement 'Header' -Resource 'MyScript' -ResourceComment 'Script for functionality X' -Link 'https://example.com/script.js'
Adds an external JavaScript file 'script.js' to the header of the HTML document with a specified comment.
```

### Example 2

```powershell
Add-HTMLScript -Placement 'Footer' -Resource 'CustomScript' -ResourceComment 'Custom script for feature Y' -Content 'function myFunction() { // code here }'
Adds custom JavaScript content to the footer of the HTML document with a specified comment.
```

### Example 3

```powershell
Add-HTMLScript -Placement 'Inline' -Resource 'InlineScript' -ResourceComment 'Inline script for page Z' -FilePath 'C:\Scripts\inline.js' -ReplaceData @{ 'placeholder' = 'replacement' }
Adds JavaScript code from a file 'inline.js' to be included inline in the HTML document with specified replacements.
```

## Parameters

**-AddComments SwitchParameter optional**

Indicates whether to add comments around the JavaScript content. By default, comments are not added.

**-Content String[] optionalposition: 4**

Specifies an array of JavaScript content as strings to be included.

**-FilePath String[] optionalposition: 5**

Specifies an array of file paths containing JavaScript code to be included.

**-Link String[] optionalposition: 3**

Specifies an array of URLs to external JavaScript files to be included.

**-Placement String optionalposition: 0**

Specifies where the JavaScript content should be placed in the HTML document. Valid values are 'Inline', 'Header', or 'Footer'. Default is 'Header'.

Possible values: `Inline`, `Header`, `Footer`

**-ReplaceData IDictionary optionalposition: 6**

Specifies a dictionary of key-value pairs to replace in the JavaScript code.

**-Resource IDictionary optionalposition: 1**

Specifies the resource containing the JavaScript content.

**-ResourceComment String optionalposition: 2**

Specifies a comment to be included with the JavaScript content.

**-SkipTags SwitchParameter optional**

Indicates whether to skip adding script tags around the JavaScript content. By default, script tags are added.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:C2422F691C492D7E4031967698BC0EDBF3C5ABC1ACFE24E1126423BBEF77B9E1 -->
