Add removal of microsoft bs apps
This commit is contained in:
195
1_Install.ps1
195
1_Install.ps1
@@ -22,13 +22,40 @@ if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
|
|||||||
|
|
||||||
Write-Host "Running with administrator privileges." -ForegroundColor Green
|
Write-Host "Running with administrator privileges." -ForegroundColor Green
|
||||||
|
|
||||||
[Environment]::UserName
|
|
||||||
$uid = $Env:UserName # Get current username for use in paths
|
$uid = $Env:UserName # Get current username for use in paths
|
||||||
|
Write-Host "Current user: $uid" -ForegroundColor Green
|
||||||
|
|
||||||
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
|
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
|
||||||
Add-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0'
|
|
||||||
Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart
|
# Check and install OpenSSH Client if not already installed
|
||||||
winget source remove msstore
|
$sshCapability = Get-WindowsCapability -Online | Where-Object { $_.Name -like "OpenSSH.Client*" }
|
||||||
|
if ($sshCapability.State -ne "Installed") {
|
||||||
|
Write-Host "Installing OpenSSH Client..." -ForegroundColor Yellow
|
||||||
|
Add-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0'
|
||||||
|
} else {
|
||||||
|
Write-Host "OpenSSH Client is already installed." -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check and enable NFS features if not already enabled
|
||||||
|
$nfsClientOnly = Get-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly"
|
||||||
|
$nfsInfrastructure = Get-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure"
|
||||||
|
|
||||||
|
if ($nfsClientOnly.State -ne "Enabled" -or $nfsInfrastructure.State -ne "Enabled") {
|
||||||
|
Write-Host "Enabling NFS Client features..." -ForegroundColor Yellow
|
||||||
|
Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart
|
||||||
|
} else {
|
||||||
|
Write-Host "NFS Client features are already enabled." -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 import -i .\winget.json
|
||||||
winget pin add Discord.Discord
|
winget pin add Discord.Discord
|
||||||
|
|
||||||
@@ -37,7 +64,122 @@ Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
|
|||||||
Set-Service -Name TermService -StartupType Automatic
|
Set-Service -Name TermService -StartupType Automatic
|
||||||
Start-Service -Name TermService
|
Start-Service -Name TermService
|
||||||
|
|
||||||
|
|
||||||
|
# Remove unwanted Windows apps
|
||||||
|
Write-Host "Checking and removing unwanted Windows apps..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
$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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Also remove for all users (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
|
||||||
|
|
||||||
# Font Install
|
# Font Install
|
||||||
|
Write-Host "Checking and installing fonts..." -ForegroundColor Yellow
|
||||||
$fontSourceFolder = ".\Fonts"
|
$fontSourceFolder = ".\Fonts"
|
||||||
$fontDestFolder = "C:\Windows\Fonts"
|
$fontDestFolder = "C:\Windows\Fonts"
|
||||||
$regPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
|
$regPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
|
||||||
@@ -47,10 +189,47 @@ Get-ChildItem -Path $fontSourceFolder -Filter "*.ttf" | ForEach-Object {
|
|||||||
$fontFile = $_.FullName
|
$fontFile = $_.FullName
|
||||||
$fontName = $_.BaseName
|
$fontName = $_.BaseName
|
||||||
$destFile = Join-Path -Path $fontDestFolder -ChildPath $_.Name
|
$destFile = Join-Path -Path $fontDestFolder -ChildPath $_.Name
|
||||||
|
$regName = "$fontName (TrueType)"
|
||||||
|
|
||||||
Copy-Item -Path $fontFile -Destination $destFile -Force
|
# Check if font file already exists in destination
|
||||||
New-ItemProperty -Path $regPath -Name "$fontName (TrueType)" -Value $_.Name -PropertyType String -Force
|
$fontExists = Test-Path -Path $destFile
|
||||||
|
|
||||||
|
# Check if registry entry already exists
|
||||||
|
$regExists = $false
|
||||||
|
try {
|
||||||
|
$regValue = Get-ItemProperty -Path $regPath -Name $regName -ErrorAction SilentlyContinue
|
||||||
|
$regExists = ($regValue -ne $null)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$regExists = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only install if font file doesn't exist or registry entry is missing
|
||||||
|
if (-not $fontExists -or -not $regExists) {
|
||||||
|
try {
|
||||||
|
Write-Host "Installing font: $($_.Name)..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
# Copy font file if it doesn't exist
|
||||||
|
if (-not $fontExists) {
|
||||||
|
Copy-Item -Path $fontFile -Destination $destFile -Force
|
||||||
|
Write-Host " - Copied font file to Windows\Fonts" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " - Font file already exists, skipping copy" -ForegroundColor Gray
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add/update registry entry if it doesn't exist
|
||||||
|
if (-not $regExists) {
|
||||||
|
New-ItemProperty -Path $regPath -Name $regName -Value $_.Name -PropertyType String -Force | Out-Null
|
||||||
|
Write-Host " - Added registry entry" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " - Registry entry already exists, skipping" -ForegroundColor Gray
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Failed to install font $($_.Name): $_"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Font $($_.Name) is already installed (file and registry entry exist)" -ForegroundColor Green
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Fonts installed for all users. Restart may be required."
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user