> For the complete documentation index, see [llms.txt](https://documentation.2pintsoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.2pintsoftware.com/osd-toolkit/4.0/installation/adding-osd-toolkit-to-the-boot-image/unattended-builds.md).

# Unattended builds

The Boot Image Customizer can also run without the console, from an elevated Windows PowerShell prompt or in a scheduled task. Use the signed `Update-CustomBootImage.ps1` from the OSD Toolkit release zip, or run it from the extension's `bin` folder.

## Examples

```powershell
# Adds OSD Toolkit only to a WIM file. Configuration Manager is not used.
.\Update-CustomBootImage.ps1 -Unattended -WimPath D:\Boot\boot.wim -OptionalComponents None

# Opens the customizer window for a boot image
.\Update-CustomBootImage.ps1 -PackageID "PS100005"

# Lists the boot images of the site
.\Update-CustomBootImage.ps1 -Unattended

# Runs the build with the saved settings of the boot image
.\Update-CustomBootImage.ps1 -PackageID "PS100005" -Unattended

# Runs the build with explicit paths
.\Update-CustomBootImage.ps1 -PackageID "PS100005" -Unattended `
    -StifleRSourcePath "D:\Sources\StifleR Client" `
    -StifleRConfigPath "D:\Sources\StifleR\Client.2psimport" `
    -OSDToolkitPath "D:\Sources\OSDToolkit" `
    -OptionalComponents "WinPE-WMI","WinPE-NetFx","WinPE-PowerShell","WinPE-Scripting"
```

## Parameters

| Parameter             | Description                                                                                                                                                                                    |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-PackageID`          | The boot image package ID. The WIM path is read from Configuration Manager.                                                                                                                    |
| `-WimPath`            | A WIM file to customize directly. Without `-PackageID`, Configuration Manager is not used and no distribution points are updated.                                                              |
| `-Unattended`         | Runs the build without the customizer window.                                                                                                                                                  |
| `-StifleRSourcePath`  | The StifleR Client source (`.zip`, `.msi`, extracted folder or installed client folder).                                                                                                       |
| `-StifleRConfigPath`  | The `.2psimport` configuration file. Needs `-StifleRSourcePath`.                                                                                                                               |
| `-OSDToolkitPath`     | The folder with `OSDToolkit.exe` and `OSDToolkit-EnableBranchCache.ps1`. Default: the script's own folder, when `OSDToolkit.exe` is there (as in the release zip). `None` adds no OSD Toolkit. |
| `-CertPath`           | A root CA certificate (`.cer`).                                                                                                                                                                |
| `-MountPath`          | An empty local folder to mount the WIM in. Default: `%TEMP%\BootWim`.                                                                                                                          |
| `-OptionalComponents` | The WinPE optional components to add. `None` adds none.                                                                                                                                        |
| `-AdkPath`            | The ADK `WinPE_OCs` folder, if it is not found automatically.                                                                                                                                  |
| `-SiteCode`           | The site code, if it is not found automatically.                                                                                                                                               |
| `-SkipDpUpdate`       | Does not update the distribution points.                                                                                                                                                       |
| `-NoBackup`           | Does not create the `.bak` backup.                                                                                                                                                             |
| `-NoMountCleanup`     | Does not clean up a mount left behind by an earlier failed run.                                                                                                                                |
| `-LogFile`            | Writes the build log to this file. Default with `-Unattended`: `Logs\Build_<date>_<time>.log` next to the script.                                                                              |

Parameters you leave out are taken from the saved settings of the boot image.

Every input is checked before the WIM is touched. When something is missing or wrong, the log lists each problem and the WIM is not changed.

## Exit codes

| Exit code | Description                                                            |
| --------- | ---------------------------------------------------------------------- |
| `0`       | The WIM was built, and the distribution points updated when asked for. |
| `1`       | Stopped. Unless the log says otherwise, the WIM is unchanged.          |
| `2`       | The WIM was built, but updating the distribution points failed.        |

## Files and logs

| What           | Where                                                                                                                                                                                                                     |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Saved settings | `<AdminConsole>\Extensions\4e8b21c4-9a10-482a-bc91-53642345091a\<version>\bin\config.<PackageID>.json`, one per boot image. `config.json` in the same folder is the starting point for a boot image without its own file. |
| Build logs     | `<AdminConsole>\Extensions\4e8b21c4-9a10-482a-bc91-53642345091a\<version>\bin\Logs\Build_<date>_<time>.log`, or `Logs\` next to the script when it runs on its own.                                                       |
| WIM backup     | Next to the boot image's WIM, as `<wim>.bak`.                                                                                                                                                                             |
| Console log    | `<AdminConsole>\AdminUILog\SmsAdminUI.log`                                                                                                                                                                                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.2pintsoftware.com/osd-toolkit/4.0/installation/adding-osd-toolkit-to-the-boot-image/unattended-builds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
