how to run PowerShell from SetupComplete.cmd

See also: all the recipes and the intro

In case if you didn't know, %windir%\Setup\Scripts\SetupComplete.cmd is an user script that runs at the end of Windows setup, in case if you place it there either in advance or from some script that you run in the middle of setup from Unattend.xml. SetupComplete.cmd runs after the system had already booted from the newly installed image. But not all the environment is set up at that point yet, so running PowerShell from it requires a little help:

set PSExecutionPolicyPreference=Unrestricted
powershell "%systemdrive%\MyScript.ps1" -Argument >"%systemdrive%\myscript_log.txt" 2>&1