Issues with Post-Setup PS1 File - Not running when connected to Internet (winget)

Kingells684

New Member
Messages
9
Reaction score
1
Hi All,

Apologies in advance if this has been covered in a previous thread but I couldn't spot anything about it.

I'm back on my Winget shenanigans and I've found that the latest ISO download for Windows 11 actually includes a version of Winget that works off the bat with the standard winget install commands.

I switched out my old scripts that installs Winget and the dependencies and switched to purely a PS1 file with the Winget install commands but now I'm running into a weird issue.

If the device is connected to the internet (Via Ethernet for this machine), it goes through the normal Windows installation, but when it logs in as the user, no Powershell window runs, and none of my apps get installed.

If the device is disconnected from the internet, when the machine boots to the desktop, my script runs! (The script checks for an internet connection and doesn't run until it can ping google).


I saw some mentions of an update Win 11 does when installing, so I tried disabling Dynamic Updates and implementing a DisableCloudContent reg key into the build, and I haven't spotted it do the update pre-desktop but it hasn't made a change.

Is my script possibly running too fast and triggering before actually reaching the desktop? Is there still something Windows 11 is doing when installing that bricks the post-logon stuff if it's connected to the internet?

Real weird, be interested to hear yours guys thoughts. I've attached my Preset and the PS1 file I use in the Zip,

Thanks!
 

Attachments

There's a known issue with running winget in Post-Setup. winget isn't a separate app, it's part of the DesktopAppInstaller UWP package.

All UWP packages (even free ones) require a per-machine license to run. Normally when your newly installed Windows reaches Post-Setup, DesktopAppInstaller hasn't finished acquiring a license from MS. It will after a few minutes, when a background task runs.

To make winget work from Post-Setup, you need to force this behavior (rather than wait).
Code:
powershell "Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"
winget install -e --id Google.Chrome --accept-source-agreements --accept-package-agreements
winget install -e --id Adobe.Acrobat.Reader.64-bit --accept-source-agreements --accept-package-agreements
 
Ah okay I'll give it a try!

It's weird how the script doesn't even appear on screen when connected to the internet, but when I'm disconnected it's fine then as soon as I connect it it fires straight up.

I'll update my script and give it a whirl then report back, thanks for your help!
 
By running "Add-AppxPackage -RegisterByFamilyName", it forces Windows to get a license for winget, so it's ready for immediate use.

Otherwise you're waiting 5-10 minutes before WU starts the normal process of licensing & updating all the built-in UWP apps. If you're writing a Post-Setup script, there is no reason to sit around since you will get zero notification that WU is finished with the background task.
 
Back
Top