xmlpowershellscriptingwindows-10unattend-file

Where to place powershell script in unattend.xml


I am currently having trouble running powershell script within the unattend.xml file that I have. The powershell is supposed install applications, but the xml file can't seem to run the line for the script.

I have gone back and forth between using <FirstLogonCommands>, <RunSynchronousCommand>, and <SynchronousCommand>

<FirstLogonCommands>
   <SynchronousCommand wcm:action="add">
    <CommandLine>Powershell -ExecutionPolicy ByPass -File \\deploy\RemoteInstall\WdsClientUnattend\deploySoftware.ps1</CommandLine>
    <Description>Installs software</Description>
    <Order>1</Order>
   </SynchronousCommand>
</FirstLogonCommands>

This command is supposed run the ps1 script that installs applications from our server.


Solution

  • I'm not sure what the problem is, but if it's not necessary to have the command in the autounattend.xml file, I'd suggest you try putting the command in \sources\$OEM$\$$\Setup\Scripts\SetupComplete.cmd file.

    Make the cmd file first with the powershell command, like this

    PowerShell.exe /W Normal -ExecutionPolicy Bypass ...
    

    then test if it works correctly by running it manually. If it does, put it in the above mentioned directory and try installing windows again.