Run script after OOBE
-
ok ive done this and it works
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RunSynchronous> <RunSynchronousCommand wcm:action="add"> <Description>firstlogon</Description> <Order>1</Order> <Path>C:\Users\admin\sysprep\firstlogon.bat</Path> </RunSynchronousCommand> </RunSynchronous> </component>
and my bat is just this
@echo off C:\Users\admin\sysprep\SophosSetup.exe --quiet rmdir /Q /S C:\Users\admin\sysprep
this works but when i try to run a powershell command that needs admin it cant do it ie
powershell.exe -ExecutionPolicy Bypass -File path-to-ps1
in there i just have this
Set-LocalUser -Name “user” -PasswordNeverExpires $true
but everytime after the sysprep and it loads into windows it hasnt done it as it hasnt got admin privs
so how come cmd had admin but ps1 doesnt?
any idea please
thanks,
rob -
@robertkwild This isn’t a FOG issue at all but I would look into running your sysprep scripts in the
SetupComplete.cmd
file. I’ve never had any issues with admin privileges when running powershell scripts from it. -
-
@rodluz thanks but doesnt this need a VL key to run those scripts?
-
@robertkwild I don’t think so. A couple years ago, I imaged a Windows 11 Home machine without any license key and used the SetupComplete.cmd script without any issue.
It won’t run it if using an OEM key, though. -
solved…
i used a computer startup script
script name:
C:\Users\admin\sysprep\firstlogon.ps1script parameters:
powershell -ep Bypassand heres the script (just made a rough one to test and every command ran as when i logged in after the pc syspreped all commands worked)
start-process 'C:\Users\admin\sysprep\Firefox Setup 138.0.exe' /S -wait Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\AdventNet\DesktopCentral\DCAgent\" -Name "ImagedComputer" -Force Remove-Item -Path "HKLM:\SOFTWARE\Wow6432Node\AdventNet\DesktopCentral\DCAgent\SystemDetails" -Force Set-LocalUser -Name "user01" -PasswordNeverExpires $true Set-LocalUser -Name "it" -PasswordNeverExpires $true remove-item -path C:\Users\admin\sysprep -recurse -force