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 # Import & execute regfile
function RegImport { function RegImport {
param param
@@ -510,38 +531,18 @@ else {
} }
'RemoveCommApps' { 'RemoveCommApps' {
Write-Output "> Removing Mail, Calendar and People apps..." Write-Output "> Removing Mail, Calendar and People apps..."
$appsList = '*Microsoft.windowscommunicationsapps*', '*Microsoft.People*' $appsList = '*Microsoft.windowscommunicationsapps*', '*Microsoft.People*'
RemoveSpecificApps $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 }
}
Write-Output "" Write-Output ""
continue continue
} }
'RemoveW11Outlook' { 'RemoveW11Outlook' {
Write-Output "> Removing new Outlook for Windows app..." Write-Output "> Removing new Outlook for Windows app..."
$appsList = '*Microsoft.OutlookForWindows*' $appsList = '*Microsoft.OutlookForWindows*'
RemoveSpecificApps $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 }
}
Write-Output "" Write-Output ""
continue continue