2

Currently we are Deploying our Windows 10 Machines with Windows Deployment Services(WDS) with a unattend.xml file for basic settings. From time to time there are machines which won't activate windows automatically(we are using OEM licences). This seems to happen only with new machines on which Windows wasn't activated before.

To "bypass" this issue, I've created a small powershell-script which gets the windows-key from bios/uefi and activates the windows copy with this key. The Script is working well and I would like to add it to the unattend.xml to run it automatically after setup. I would like to store the script on our fileserver(to avoid changing the image each time when I changed the script) and run it from there. Where do I have to configure this in the unattend.xml file ? Is this even possible ?

I found a topic on serverfault(How can I run a PowerShell script during the specialize pass of a WDS deploy?) where they talk about this. In the comments section they talk about adding it to the OOBE and autologon section. Since I'm a bit confused(and the topic is really old), I would like to ask: - Do I have to configure an autologon with the right credentials and run the script under this autologon user ? And if so: how is this done in the unattend.xml File ?

Elliot Huffman
  • 1,169
  • 1
  • 10
  • 22
SaintCore
  • 83
  • 2
  • 3
  • 8

1 Answers1

8

To execute Powershell scripts automatically via unattend.xml you are going to want to configure the run synchronous command entry(s) for your script.

Open Windows SIM to the unattend file that you would like to mod. open the components tab and expand the *Microsoft-Windows-Deployment* entry.

Add the command execution item.

After you have added the item to the unattend.xml, You can configure the command that is run in the box that says path.

For powershell scripts on a server you might use a command like:

powershell -File "\\remote-computer\some\dir\script.ps1".

For powershell scripts on a local computer, the syntax is like this:

powershell -File "C:\path\to\dir\script.ps1".

If you want to execute a standalone powershell cmdlet you can use this command style:

powershell verb-noun -argument(s).

Enter the command to be executed.


Optional:

Enter the credentials that you need to execute the command. Run as info/credentials


Links:


Tl;Dr:

Use Windows SIM to add synchronous or asynchronous commands to your unattend.xml.

Elliot Huffman
  • 1,169
  • 1
  • 10
  • 22