> For the complete documentation index, see [llms.txt](https://osdeploy.gitbook.io/osdbuilder/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osdeploy.gitbook.io/osdbuilder/docs/osbuild/content-directory/scripts.md). Agents can also search and read this documentation through its [MCP server](https://osdeploy.gitbook.io/osdbuilder/~gitbook/mcp).

# Scripts

**This guide was written for OSBuilder, but the same principals apply to OSDBuilder**

There are thousands of customizations that can be added to a Windows Image, and it would be impossible for OSBuilder to contain Parameters for all of these. This is why New-OSBuild has the ability to execute PowerShell Scripts.

## Add a Script <a href="#add-a-script" id="add-a-script"></a>

You can easily add a Script to OSBuilder by placing the PowerShell Script in the OSBuilder\Content\Scripts directory

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LDKRxGiKLYjW1gana2O%2F-LTaKipAX6vvcJHBvyUu%2F-LTaLjgRR0oBz366Hd3F%2F2018-12-13_0-56-41.png?alt=media\&token=f2678de9-8f08-4d6e-9074-6b59865224a7)

## New-OSBuildTask <a href="#new-osbuildtask" id="new-osbuildtask"></a>

Once a PowerShell Script has been added, you can create a [**`New-OSBuildTask`**](https://osdeploy.gitbook.io/osdbuilder/docs/osbuild/content-directory/scripts.md) and select the Scripts you want to include

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LDKRxGiKLYjW1gana2O%2F-LTaKipAX6vvcJHBvyUu%2F-LTaM6q5pRTMwskoATtc%2F2018-12-13_0-51-44.png?alt=media\&token=a6af6592-49ee-4189-bb3a-0016fc974c9e)

## Edit an Existing New-OSBuildTask <a href="#edit-an-existing-new-osbuildtask" id="edit-an-existing-new-osbuildtask"></a>

If you know how to edit a JSON file, you can easily add a Script to an existing [**`New-OSBuildTask`**](https://osdeploy.gitbook.io/osdbuilder/docs/osbuild/content-directory/scripts.md)**`​`**

## Remove-OneDriveSetup.ps1 <a href="#remove-onedrivesetup-ps1" id="remove-onedrivesetup-ps1"></a>

Here is a good example of how to properly format a PowerShell Script to remove OneDrive Setup from the Registry and to delete the Shortcut

## Add-DesktopIcons.ps1 <a href="#add-desktopicons-ps1" id="add-desktopicons-ps1"></a>

This script will add This PC, Network, and Control Panel to the Desktop for all users

## New-OSBuild -Execute <a href="#new-osbuild-execute" id="new-osbuild-execute"></a>

When executing the [**`New-OSBuild`**](https://osdeploy.gitbook.io/osdbuilder/docs/osbuild/content-directory/scripts.md) with the Scripts in the Task, you should see the scripts executed in the PowerShell Console

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LDKRxGiKLYjW1gana2O%2F-LTaR3QcZz1_cYes_Tp8%2F-LTaRHOK8n8zGvqF5MqM%2F2018-12-13_1-17-34.png?alt=media\&token=e951c7ff-fd83-4db6-8ee1-e54cc67d3942)

## Results <a href="#results" id="results"></a>

The screenshots below should speak for themselves

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LDKRxGiKLYjW1gana2O%2F-LTaR3QcZz1_cYes_Tp8%2F-LTaTAkqIiDTUq7Bp49G%2F2018-12-13_1-29-15.png?alt=media\&token=1e59e8a7-af17-4431-a762-8a4cd9ee7826)

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LDKRxGiKLYjW1gana2O%2F-LTaR3QcZz1_cYes_Tp8%2F-LTaTCquwyzh0Ymyif45%2F2018-12-13_1-29-29.png?alt=media\&token=12fbba95-5cb9-40e1-ab43-864311f89399)

## OSBuilder.Public Git <a href="#osbuilder-public-git" id="osbuilder-public-git"></a>

These scripts are available on Github as part of my OSBuilder.Public Git

## Sharing <a href="#sharing" id="sharing"></a>

If you find this useful, I would appreciate it if you could come up with a script for me to add!

​
