> For the complete documentation index, see [llms.txt](https://docs.foundryosd.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.foundryosd.com/foundry-osd/customization/post-installation.md).

# Post-installation

Use **Customization > Post-installation** to run your own scripts, commands and installers on the target device after Windows is installed and before the first sign-in. Your actions run in the order of the list, after Foundry's own setup tasks.

<figure><img src="https://64695594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdn0pr5zia6oG2DU1R1Pn%2Fuploads%2Fgit-blob-3956f574e30c7e5710d9769b7a6ad86fc4598914%2Ffoundry-osd-post-installation-01-ordered-actions.png?alt=media" alt="Foundry OSD Post-installation page with five enabled actions in order: a software installation, a restart, a second software installation, a command line and a PowerShell script"><figcaption><p>Actions run from top to bottom. Content status shows whether the imported files are still in the local library.</p></figcaption></figure>

## Before you start

* Every script and installer must run to the end without a prompt. Actions run as SYSTEM, the Windows built-in account with full rights on the device, with no signed-in user, no window and no keyboard input.
* Actions that use imported files need, during deployment, the complete ISO or USB drive or, with the [network cache](https://docs.foundryosd.com/foundry-osd/network-cache.md) on, a share of the device IP scope: ISO files and USB drives then no longer carry them. A PXE boot image alone does not carry them: see [what each media type carries](https://docs.foundryosd.com/foundry-osd/media.md#what-each-media-type-carries).
* Use content built for the Windows architecture you deploy, x64 or ARM64.

## Configure actions

1. Open **Customization > Post-installation** and turn on the switch in the page header.
2. On the toolbar above the table, select **Add action**, then **PowerShell script (.ps1)**, **Command line**, **Software (.exe/.msi)** or **Restart Windows**.
3. Enter a **Name**. The technician sees it in the console after the restart.
4. Under **Package content**, select **Import file** or **Import folder**. Content is optional for **Command line** and not used by **Restart Windows**.
5. Fill in the fields of the action type, then read **Command preview**: it is the command Foundry will run. `{ContentRoot}` and `{LogRoot}` appear in the preview only; they are not replaced if you type them in your arguments.
6. Review **Execution settings**, defined in [Execution settings](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md#execution-settings): the timeout is 1800 seconds by default. Then select **Save**.
7. Select a row, then use **Move up** and **Move down** on the toolbar to set the order. **Edit action**, **Disable** or **Enable**, and **Remove** also act on the selected row.

| Action type                  | Fields                                                                                                                        |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **PowerShell script (.ps1)** | **Script or installer path (relative to content)**, **PowerShell arguments**, **Script arguments**                            |
| **Command line**             | **Command line**, one line with its arguments                                                                                 |
| **Software (.exe/.msi)**     | **Script or installer path (relative to content)**, **Arguments or MSI properties**, **Generate installation log** (MSI only) |
| **Restart Windows**          | **Restart delay (seconds)**, 0 to 86400, default 0                                                                            |

Foundry adds nothing to your command: enter silent and no-restart switches yourself, for example `/qn /norestart` for an MSI.

{% hint style="warning" %}
Foundry waits for every process an action starts, not only the first one. An updater, a tray application or the installed application left running holds the action until its timeout, and the sequence then stops.
{% endhint %}

What Foundry runs for each type, and what it does with each exit code, is in [How actions run](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md).

<figure><img src="https://64695594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdn0pr5zia6oG2DU1R1Pn%2Fuploads%2Fgit-blob-88d0b90681d9dc855a336a31fd730dd574309b03%2Ffoundry-osd-post-installation-02-action-dialog.png?alt=media" alt="Action dialog for an MSI software action with its package content, installer path, arguments, Generate installation log, execution settings and command preview"><figcaption><p>The command preview shows the exact command the action runs.</p></figcaption></figure>

## Prepare content

* Import a folder when the script or installer needs other files, such as a transform or a CAB file. Relative paths are kept.
* Leave **Working directory (relative; empty uses content root)** empty to run from the root of the imported content, or enter a folder inside it. Without content, a command runs from a temporary folder.
* Foundry copies the content to its library in `%LOCALAPPDATA%\Foundry\Packages\PreOobe`. To pick up a new version of your source, select **Edit action** and import again; **Refresh** only rechecks the library copy.
* An import is refused beyond certain path lengths and counts: see [Import limits](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md#import-limits).

## Restarts and secrets

Never let a script or an installer restart Windows itself: the action is then marked interrupted and the sequence stops. Add a **Restart Windows** action where the restart must happen, or declare the restart code of the installer. See [Restarts](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md#restarts).

{% hint style="warning" %}
Do not pass passwords, keys or tokens as arguments. The full command line of every action is saved in `C:\Windows\Temp\Foundry\State\PreOobe\plan.json` and its output in `C:\Windows\Temp\Foundry\Logs\PreOobe`. Both stay on the device after deployment.
{% endhint %}

## Check the result

* On the page, no warning bar is shown and every enabled action has **Available** or **Not required** under **Content status**.
* On a test device, after the restart, the **Foundry Post-installation** console lists Foundry's setup tasks, then your actions under the names you gave them, then `Cleanup`. Every action shows `[Succeeded]` and the console reports `Post-installation completed.` Script output is not shown: [After the restart](https://docs.foundryosd.com/foundry-deploy/after-the-restart.md) explains each line and the restarts.

## If something goes wrong

| What you see in Foundry OSD                                                                                          | What to do                                                                                                                                                                                                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| "Content import failed. Check access, available space, file names and path lengths."                                 | One message for every [import limit](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md#import-limits). Shorten paths, copy the content to a plain local folder or free space, then import again. The Foundry OSD log names the limit, for example `PreOobe.InvalidPackagePath`. |
| "Import the missing content for "\<name>"."                                                                          | Select **Edit action**, import the same file or folder, then **Save**.                                                                                                                                                                                                                                                   |
| "The configuration changed while you were editing. Open the action again."                                           | The configuration was replaced while the dialog was open, for example by a sync. Reopen the action.                                                                                                                                                                                                                      |
| "Custom Windows image media preparation failed." after "Technical details:", with a code that starts with `PreOobe.` | The failure comes from Post-installation content, even when no custom image is configured. See [Content cannot be copied to the media](https://docs.foundryosd.com/troubleshooting/media-creation/usb-drive-and-device-start.md#media-content).                                                                          |

Failures on the target device are in [After the restart troubleshooting](https://docs.foundryosd.com/troubleshooting/after-the-restart.md).

## Related

* [How actions run](https://docs.foundryosd.com/foundry-osd/customization/post-installation/how-actions-run.md)
* [After the restart](https://docs.foundryosd.com/foundry-deploy/after-the-restart.md)
* [After the restart troubleshooting](https://docs.foundryosd.com/troubleshooting/after-the-restart.md)
* [Unattend (custom answer files)](https://docs.foundryosd.com/foundry-osd/customization/unattend.md)


---

# 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://docs.foundryosd.com/foundry-osd/customization/post-installation.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.
