Created
May 25, 2024 08:24
-
-
Save a1678991/8aff85968689514390ca6b9536423482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to check if the script is running as Administrator | |
function Test-IsAdmin { | |
$currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
} | |
# If not running as Administrator, restart the script with elevated privileges | |
if (-not (Test-IsAdmin)) { | |
Write-Output "Restarting script with elevated privileges..." | |
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs | |
exit | |
} | |
# Array of packages to install | |
$packages = @( | |
"Microsoft.DotNet.DesktopRuntime.8", | |
"Microsoft.Sysinternals.ProcessExplorer", | |
"Microsoft.UI.Xaml.2.8", | |
"Microsoft.VCRedist.2005.x64", | |
"Microsoft.VCRedist.2005.x86", | |
"Microsoft.VCRedist.2008.x64", | |
"Microsoft.VCRedist.2008.x86", | |
"Microsoft.VCRedist.2010.x64", | |
"Microsoft.VCRedist.2010.x86", | |
"Microsoft.VCRedist.2012.x64", | |
"Microsoft.VCRedist.2012.x86", | |
"Microsoft.VCRedist.2013.x64", | |
"Microsoft.VCRedist.2013.x86", | |
"Microsoft.VCRedist.2015+.x64", | |
"Microsoft.VCRedist.2015+.x86", | |
"Microsoft.XNARedist" | |
) | |
# Install each package | |
foreach ($package in $packages) { | |
winget install --id $package --silent | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment