Added Additional Software
This commit is contained in:
parent
2276448d87
commit
7db5c4b915
83
Tasks/System-Tasks/Additional-Software.ps1
Normal file
83
Tasks/System-Tasks/Additional-Software.ps1
Normal file
@ -0,0 +1,83 @@
|
||||
# Silent Software Installation Script using Winget
|
||||
|
||||
# Arrays of software to install and remove
|
||||
# Add or remove applications by modifying these arrays
|
||||
# Check the name of Winget Packages here: https://winget.run
|
||||
$applicationsToInstall = @(
|
||||
# Add more applications to install here
|
||||
#"Notepad++.Notepad++"
|
||||
)
|
||||
|
||||
$applicationsToRemove = @(
|
||||
# Add applications to remove here
|
||||
#"Mozilla.Firefox"
|
||||
#"7zip.7zip"
|
||||
)
|
||||
|
||||
# Function to check if Winget is installed
|
||||
function Test-WinGet {
|
||||
try {
|
||||
$wingetVersion = winget --version
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Host "Winget is not installed. Installation failed." -ForegroundColor Red
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Function to install and uninstall applications
|
||||
function Manage-Applications {
|
||||
# Install applications from the install array
|
||||
foreach ($app in $applicationsToInstall) {
|
||||
try {
|
||||
Write-Host "Installing $app" -ForegroundColor Yellow
|
||||
winget install -e --id $app --silent --accept-source-agreements --accept-package-agreements | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "$app installed successfully" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "Failed to install $app" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Error installing $app $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
# Uninstall applications from the remove array
|
||||
foreach ($app in $applicationsToRemove) {
|
||||
try {
|
||||
Write-Host "Uninstalling $app" -ForegroundColor Yellow
|
||||
winget uninstall --id $app --silent --accept-source-agreements | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "$app uninstalled successfully" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "Failed to uninstall $app" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Error uninstalling $app $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Main script execution
|
||||
Write-Host "Starting software management..." -ForegroundColor Cyan
|
||||
|
||||
# Check if script is running as administrator
|
||||
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Host "Script must be run as Administrator. Installation failed." -ForegroundColor Red
|
||||
Exit 1
|
||||
}
|
||||
|
||||
# Check if Winget is installed and proceed with installation
|
||||
if (Test-WinGet) {
|
||||
Manage-Applications
|
||||
Write-Host "Software management completed!" -ForegroundColor Green
|
||||
Exit 0
|
||||
}
|
||||
else {
|
||||
Exit 1
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user