2

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.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
Jrpsd
  • 53
  • 1
  • 5
  • What does "can't seem to run the line for the script" mean? Are you getting an error message? (Remember: We can't see your screen.) – Bill_Stewart Jul 03 '19 at 17:56
  • According to the setuperr log, it says that it is having issues running the FirstLogonCommands. The description given is that "The setting is not defined in this context." – Jrpsd Jul 03 '19 at 18:20
  • Update your question with all the errors you are getting. – Bill_Stewart Jul 03 '19 at 19:11

1 Answers1

1

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.

GChuf
  • 1,135
  • 1
  • 17
  • 28
  • I was hoping to use the powerhsell in the unattend.xml file so that upon logging in, the application would already be installed. The powershell works aside from it not not running .msi and .bat files silently. – Jrpsd Jul 05 '19 at 15:14
  • Whatever you put in the SetupComplete.cmd file also completes before the user logs in. – GChuf Jul 05 '19 at 19:52
  • @hextech What is the /W switch for? – Aboodnet Jun 05 '20 at 21:04
  • /W stands for -WindowStyle. Valid values are Normal, Minimized, Maximized and Hidden. – GChuf Jul 03 '20 at 09:20