Refactored new communication apps removal option

This commit is contained in:
Raphire
2023-11-19 23:40:35 +01:00
parent e8dbbd9987
commit 6a7e2c7930

View File

@@ -85,6 +85,27 @@ function RemoveApps {
}
# Removes apps specified during function call from all user accounts and from the OS image.
function RemoveSpecificApps {
param
(
$appslist
)
Foreach ($app in $appsList)
{
$appString = $app.Trim('*')
Write-Output "Attempting to remove $appString..."
# Remove installed app for all existing users
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
# Remove provisioned app from OS image, so the app won't be installed for any new users
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }
}
}
# Import & execute regfile
function RegImport {
param
@@ -510,38 +531,18 @@ else {
}
'RemoveCommApps' {
Write-Output "> Removing Mail, Calendar and People apps..."
$appsList = '*Microsoft.windowscommunicationsapps*', '*Microsoft.People*'
Foreach ($app in $appsList)
{
$appString = $app.Trim('*')
Write-Output "Attempting to remove $appString..."
# Remove installed app for all existing users
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
# Remove provisioned app from OS image, so the app won't be installed for any new users
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }
}
RemoveSpecificApps $appsList
Write-Output ""
continue
}
'RemoveW11Outlook' {
Write-Output "> Removing new Outlook for Windows app..."
$appsList = '*Microsoft.OutlookForWindows*'
Foreach ($app in $appsList)
{
$appString = $app.Trim('*')
Write-Output "Attempting to remove $appString..."
# Remove installed app for all existing users
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
# Remove provisioned app from OS image, so the app won't be installed for any new users
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }
}
RemoveSpecificApps $appsList
Write-Output ""
continue