Add DSC configurations for user interface, Windows features, and services; implement app installation and removal scripts

- Created `DSC-UserInterfaceConfiguration.ps1` to manage user interface settings via registry changes.
- Developed `DSC-WindowsFeatures.ps1` to install OpenSSH Client and enable NFS Client features.
- Implemented `DSC-WindowsServices.ps1` to ensure Terminal Services are running and set to automatic startup.
- Added `PS-InstallApps.ps1` to manage app installations and remove the msstore source if it exists.
- Created `PS-RemoveApps.ps1` to remove unwanted apps, provisioned packages, and handle Office applications via winget.
This commit is contained in:
2025-09-28 11:59:28 -05:00
parent 7e9ad6b9eb
commit 79df17763a
11 changed files with 1842 additions and 360 deletions

193
PS-RemoveApps.ps1 Normal file
View File

@@ -0,0 +1,193 @@
# === Admin Check ===
# set-executionpolicy unrestricted
# Check if running as administrator
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "This script requires administrator privileges. Attempting to restart as administrator..." -ForegroundColor Yellow
# Get the current script path
$scriptPath = $MyInvocation.MyCommand.Path
# Restart the script with administrator privileges
try {
Start-Process PowerShell -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File `"$scriptPath`""
exit
}
catch {
Write-Error "Failed to restart as administrator. Please run this script as administrator manually."
Write-Host "Right-click on PowerShell and select 'Run as administrator', then run this script again." -ForegroundColor Red
pause
exit 1
}
}
Write-Host "Running with administrator privileges." -ForegroundColor Green
$uid = $Env:UserName # Get current username for use in paths
Write-Host "Current user: $uid" -ForegroundColor Green
# === Install Features/Enable Services ===
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
powershell "$scriptDir\DSC-WindowsFeatures.ps1"
powershell "$scriptDir\DSC-WindowsServices.ps1"
# === Disable Telemetry ===
powershell "$scriptDir\DSC-TelemetryPrivacySecurity.ps1"
# === Remove Apps ===
$appsToRemove = @(
"Microsoft.MicrosoftSolitaireCollection", # Solitaire
"Microsoft.MicrosoftOfficeHub", # Office preinstalls
"Microsoft.Windows.Photos", # Photos
"Microsoft.Copilot", # Copilot
"Microsoft.BingNews", # News
"Microsoft.BingWeather", # Weather
"Clipchamp.Clipchamp", # Clipchamp
"MSTeams", # Teams
"Microsoft.Todos", # To-Do
"Microsoft.WebMediaExtensions", # Media extensions
"Microsoft.WindowsMediaPlayer", # Legacy Media Player (if exists)
"Microsoft.ZuneMusic", # Music app
"Microsoft.ZuneVideo", # Movies & TV app (if exists)
"Microsoft.Media.Player", # New Windows Media Player (if exists)
"Microsoft.OutlookForWindows", # New Outlook app
"Microsoft.Office.OneNote", # OneNote (AppX version)
"Microsoft.MicrosoftOfficeHub", # Office Hub
"7EX16E2Z690YF.LinkedInforWindows", # LinkedIn (actual package name)
"LinkedIn.LinkedIn", # LinkedIn (alternative name)
"Microsoft.OneDrive" # OneDrive (if exists as app package)
)
foreach ($app in $appsToRemove) {
$installedApp = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue
if ($installedApp) {
try {
Write-Host "Removing $app..." -ForegroundColor Red
Remove-AppxPackage -Package $installedApp.PackageFullName -ErrorAction Stop
Write-Host "Successfully removed $app" -ForegroundColor Green
}
catch {
Write-Warning "Failed to remove $app`: $_"
}
}
else {
Write-Host "$app is not installed or already removed" -ForegroundColor Gray
}
}
# === Remove Provisioned Packages ===
Write-Host "Checking and removing provisioned app packages for all users..." -ForegroundColor Yellow
foreach ($app in $appsToRemove) {
$provisionedApp = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $app }
if ($provisionedApp) {
try {
Write-Host "Removing provisioned package for $app..." -ForegroundColor Red
Remove-AppxProvisionedPackage -Online -PackageName $provisionedApp.PackageName -ErrorAction Stop
Write-Host "Successfully removed provisioned package for $app" -ForegroundColor Green
}
catch {
Write-Warning "Failed to remove provisioned package for $app`: $_"
}
}
else {
Write-Host "Provisioned package for $app is not found or already removed" -ForegroundColor Gray
}
}
Write-Host "App removal process completed." -ForegroundColor Green
# Remove unwanted Office applications via winget
Write-Host "Checking and removing unwanted Office applications..." -ForegroundColor Yellow
# Cache winget list to avoid multiple calls (it's slow)
Write-Host "Getting installed applications list (this may take a moment)..." -ForegroundColor Gray
$wingetList = winget list | Out-String
$officeAppsToRemove = @(
"Microsoft.OneDrive", # OneDrive (if exists as winget package)
"OneNoteFreeRetail - en-us", # Microsoft OneNote - en-us
"OneNoteFreeRetail - es-es", # Microsoft OneNote - es-es
"OneNoteFreeRetail - fr-fr", # Microsoft OneNote - fr-fr
"OneNoteFreeRetail - pt-br", # Microsoft OneNote - pt-br
"O365HomePremRetail - en-us", # Microsoft 365 - en-us
"O365HomePremRetail - es-es", # Microsoft 365 - es-es
"O365HomePremRetail - fr-fr", # Microsoft 365 - fr-fr
"O365HomePremRetail - pt-br", # Microsoft 365 - pt-br
"Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe", # Feedback Hub
"Microsoft.BingSearch_8wekyb3d8bbwe", # Bing Search (if exists)
"Microsoft.OutlookForWindows_8wekyb3d8bbwe", # New Outlook (if exists)
"MicrosoftCorporationII.MicrosoftFamily_8wekyb3d8bbwe" # Microsoft Family (if exists)
)
foreach ($app in $officeAppsToRemove) {
# Check if the app is installed using the cached winget list
$appFound = $wingetList -match [regex]::Escape($app)
if ($appFound) {
try {
Write-Host "Removing $app..." -ForegroundColor Red
winget uninstall "$app" --silent --accept-source-agreements
if ($LASTEXITCODE -eq 0) {
Write-Host "Successfully removed $app" -ForegroundColor Green
} else {
Write-Warning "winget uninstall returned exit code $LASTEXITCODE for $app"
}
}
catch {
Write-Warning "Failed to remove $app`: $_"
}
}
else {
Write-Host "$app is not installed or already removed" -ForegroundColor Gray
}
}
Write-Host "Office application removal process completed." -ForegroundColor Green
# Remove Edge Progressive Web Apps (PWAs) like LinkedIn
Write-Host "Checking and removing Edge Progressive Web Apps..." -ForegroundColor Yellow
$edgePWAPath = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Web Applications"
if (Test-Path $edgePWAPath) {
try {
$pwaFolders = Get-ChildItem -Path $edgePWAPath -Directory -ErrorAction SilentlyContinue
foreach ($folder in $pwaFolders) {
$manifestPath = Join-Path $folder.FullName "Manifest"
if (Test-Path $manifestPath) {
$manifestContent = Get-Content $manifestPath -Raw -ErrorAction SilentlyContinue
if ($manifestContent -match "linkedin" -or $manifestContent -match "LinkedIn") {
Write-Host "Found LinkedIn PWA, removing folder: $($folder.Name)" -ForegroundColor Red
Remove-Item -Path $folder.FullName -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Removed LinkedIn PWA" -ForegroundColor Green
}
}
}
}
catch {
Write-Warning "Failed to check Edge PWAs: $_"
}
} else {
Write-Host "Edge PWA directory not found" -ForegroundColor Gray
}
Write-Host "Edge PWA removal process completed." -ForegroundColor Green
# Check if msstore source exists before trying to remove it
$msstoreSource = winget source list | Select-String "msstore"
if ($msstoreSource) {
Write-Host "Removing msstore source..." -ForegroundColor Yellow
winget source remove msstore
} else {
Write-Host "msstore source is already removed or not found." -ForegroundColor Green
}
winget import -i .\winget.json
winget pin add Discord.Discord
powershell "$scriptDir\DSC-FileOperations.ps1"