Hi everyone, I will use this thread to post my problem since it's about same topic.
I have a script made by me on
Post Setup. I want this script to run after my first login after installed a new version of windows 11 using an ISO file I created on NTLITE.
My Script:
The problems I am facing is:
1) To run the script the first time using PowerShell I need to add this command line first:
Set-ExecutionPolicy RemoteSigned
or the script will not run.
My ISO file already has a Local Account set to be create with a password set to autologin.
I just need help to figure it out how to make this work, it will help me a lot if you guys can help me.
2) I attached my NTLITE Config (23H2_Config_Full.xml)) used to change my ISO`s if anybody is interested to load the configuration to add or check the alterations I made and I will add the PowerShell Script to (Apps.7ZIP = Apps.ps1).
#Script Start
# List of applications to install
$apps = @(
"7zip.7zip.exe",
"IObit.Uninstaller",
"nilesoft.shell", # Microsoft Shell Fix DropDown Menu
"9NFKC78BRS8W", # Fury CTRL DDR4 LEDs
"CrystalRich.LockHunter",
"MiniTool.PartitionWizard.Free",
"HermannSchinagl.LinkShellExtension",
"OpenDesignAlliance.ODAFileConverter",
"Bitdefender.Bitdefender",
"SoftDeluxe.FreeDownloadManager",
"Flow-Launcher.Flow-Launcher",
"Glarysoft.GlaryUtilities",
"Nlitesoft.NTLite",
"Oracle.VirtualBox",
"BlueStacks.Bluestacks",
"Microsoft.WindowsTerminal.Preview",
"Microsoft.PowerShell.Preview",
"QL-Win.QuickLook",
"keyviz",
"9NH1P86H06CG", # Radiograph Hardware Info Monitortying
"REALiX.HWiNFO",
"Logitech.GHUB",
"9MSPC6MP8FM4", # Microsoft Whiteboard
"OBSProject.OBSStudio",
"VideoLAN.VLC",
"SMPlayer.SMPlayer",
"Audacity.Audacity",
"HulubuluSoftware.AdvancedRenamer",
"IrfanSkiljan.IrfanView",
"IrfanSkiljan.IrfanView.PlugIns",
"Mirillis.Action",
"Inkscape.Inkscape",
"Canva.Canva",
"Zoom.Zoom",
"Discord.Discord",
"HandBrake.HandBrake",
"9NBLGGH5L9XT", # Instagram
"9WZDNCRFJ2WL", # Facebook
"Ubisoft.Connect",
"EpicGames.EpicGamesLauncher",
"Valve.Steam",
"ElectronicArts.EADesktop",
"Google.PlayGames.Beta",
"SomePythonThings.WingetUIStore",
"Crunchyroll.MasterofGarden"
)
# Loop through the list and install each application
foreach ($app in $apps) {
Write-Host "Installing $app"
winget install --id $app --accept-package-agreements --silent
}
#Script End
I hope someone can help me finally solve this annoying issue that I tried for so long and have failed miserably.
To help, the answer Copilot Pro gave me is:
Sure, I can guide you on how to set up a PowerShell script to run after the first login on a new version of Windows 11 using NTLite’s Post Setup option. Here are the steps:
- Create a PowerShell script: You already have your PowerShell script Apps.ps1 that installs the applications you listed.
- Change the execution policy: To run PowerShell scripts on Windows 11, you need to change the execution policy. Open PowerShell as an administrator and run the following command1:
Set-ExecutionPolicy RemoteSigned
- Set up the script to run at logon: There are two ways to set up a PowerShell script to run at logon23:
- Local Group Policy Editor: Press Win+R, type gpedit.msc, and hit Enter. Navigate to Computer Configuration > Administrative Templates > System > Scripts. Double-click on Run Windows PowerShell scripts first at user logon, logoff, select the Enabled option, and click Apply and OK.
- Registry Editor: Press Win+R, type regedit, and hit Enter. Navigate to HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System. Right-click on System > New > DWORD (32-bit) Value and name it as RunUserPSScriptsFirst. Double-click on it and set the Value data as 1.
- NTLite Post Setup option: In NTLite, navigate to the Post-Setup section. Here, you can add commands and application installations that are executed after the operating system setup completes4. According to the NTLite community, Post-Setup commands are executed by a CMD wrapper script56. So, you can add your PowerShell script here.
Here is an example of how you can add your script to the Post Setup option:
%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -File "C:\\Path\\To\\Apps.ps1"
Replace "C:\\Path\\To\\Apps.ps1" with the actual path to your Apps.ps1 script. This command will run your PowerShell script in Bypass execution policy mode, which means nothing is blocked and warnings do not appear.
Please note that you should test these steps in a controlled environment before deploying them in a production environment. Let me know if you need further assistance!
Iven so, I didn`t understand the answer, but maybe someone here will understand if it correctly the Copilot Pro answer.