Logon and run the PowerShell file

43.onsomeday

New Member
Messages
19
Reaction score
0
Add in post settings > File > After logging in (User) > C:\Scripts\DisableServices.ps1Can I write it like this?

The file was placed in the C:\Program Files\NTLite\Cache\Images\org_Win11_23H2_Korean_x64v2\sources\$OEM$\$1\Scripts folder.
 
From the Post-Setup screen, you can Add / File any script. NTLite recognizes filenames with .bat, .cmd, .ps1, and .reg extensions.
- Batch files are executed using "cmd /c"​
- PowerShell files are executing using "powershell -NoProfile -ExecutionPolicy Bypass"​
- Registry files are loaded using "reg import"​

Parameters are (optional) command line arguments for your script.
 
View attachment 12575

1. Directory to place the script file before login
D:\Program Files\NTLite\Cache\Images\org_Win11_23H2_Korean_x64v2\sources\$OEM$\$1\Scripts

2. Command to run before login
powershell.exe -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process; & 'C:\Windows\Setup\Scripts\DisableServices.ps1'" > "C:\Windows\Setup\Scripts\DisableServices.log" 2>&1

3. Command to run after login
powershell.exe -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process; & 'C:\Windows\Setup\Scripts\UltimatePerformancePower.ps1'" > "C:\Windows\Setup\Scripts\UltimatePerformancePower.log" 2>&1


Question.
1. I want to know if I have written it correctly.

2. I'm wondering if it should work without bypassing a separate policy.
 
I see that you have previous experience in adding Post-Setup tasks by editing a mounted folder. While you can still do that work, NTLite uses a different strategy so it can preserve Post-Setup actions in the preset.

1. Don't copy your files to NTLite's cache folders. When you Add / File, NTLite will automatically copy those files to its private staging folder. This allows NTLite to remember the file's source location, and reload it from there.

2. When you call a PS script file using "-NoProfile -ExecutionPolicy Bypass", you can run the script one-time without permanently changing the Execution Policy for Windows or your profile. Sometimes "-NoProfile -ExecutionPolicy Bypass" is aliased as "-nop -ep bypass".

"powershell -ExecutionPolicy Bypass" for -Command has no effect. Execution Policy only applies to scripts, and not any single -Command line. So you can replace it with "powershell -Command".

3. For every .ps1 script loaded into Post-Setup, NTLite will auto-create a new command with "-NoProfile -ExecutionPolicy Bypass -File" inserted for you. There is nothing more required, unless you want to enter optional arguments passed to the script in the Parameters box.

4. If you wanted to manually create a new command line, it must be in the form of a Command and its optional Parameters.

CommandParameters
cmd.exe/c copy C:\Windows\Setup\Files\file.txt D:\Folder
powershell-C "Set-WindowsReservedStorageState -State Disabled"
wscriptC:\Users\GARLIN\Downloads\invisible.vbs cmd /c SCRIPT.BAT
 
Back
Top