Winget for windows server 2022 install scripts with .ps1 execution disabled by domain admin #5900
Coresi7
started this conversation in
Configuration
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Tested on a pure new Windows Server 2022 with .ps1 execute disabled (Which means you cannot use winge-install). Copy and paste code into .ps1 file or elevated interactive powershell window.
Will try to download and install winget and its dependencies packages from latest release. so please cd or pushd to a temporary folder.
Single line version, best choice if you HAVE to execute it in an elevated interactive powershell window.
$progressPreference='silentlyContinue';$r=Invoke-RestMethod 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' -Headers @{'User-Agent'='PowerShell'}; $b=$r.assets|?{$_.name -match 'Microsoft\.DesktopAppInstaller.*\.msixbundle'}|select -First 1; $d=$r.assets|?{$_.name -match 'DesktopAppInstaller_Dependencies.*\.zip'}|select -First 1; $l=$r.assets|?{$_.name -match 'License.*\.xml'}|select -First 1; if(-not $b -or -not $d -or -not $l){Write-Error 'Missing required assets';exit 1}; Invoke-WebRequest $b.browser_download_url -OutFile $b.name;Invoke-WebRequest $d.browser_download_url -OutFile $d.name;Invoke-WebRequest $l.browser_download_url -OutFile $l.name;Expand-Archive -Path $d.name -DestinationPath .\Dependencies -Force;Get-ChildItem .\Dependencies -Recurse -File | ?{$_.Extension -match '\.msixbundle$|\.msix$|\.appx$'} | % { Write-Information "Installing $($_.FullName)"; Add-AppxPackage $_.FullName }; Add-AppxProvisionedPackage -Online -PackagePath .\$($b.name) -LicensePath .\$($l.name) -VerboseDetailed expanded version, same as above, best choice if you can save it to .ps1 and execute it with admin priviledge.
Beta Was this translation helpful? Give feedback.
All reactions