Actualiser powershell/Remove-BuiltInApps.ps1
This commit is contained in:
@@ -53,12 +53,12 @@ foreach ($App in $AppsToRemove) {
|
||||
$ProvPkg = Get-AppxProvisionedPackage -Online | Where-Object DisplayName -eq $App.Package
|
||||
if ($ProvPkg) {
|
||||
$ProvPkg | Remove-AppxProvisionedPackage -Online -ErrorAction Stop
|
||||
Write-Host "✔ Provisioned package removed: $($App.Name)" -ForegroundColor Green
|
||||
Write-Host ("✔ Provisioned package removed: {0}" -f $App.Name) -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "No provisioned package found for $($App.Name)" -ForegroundColor Yellow
|
||||
Write-Host ("No provisioned package found for {0}" -f $App.Name) -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Failed to remove provisioned package for $($App.Name): $_"
|
||||
Write-Warning ("Failed to remove provisioned package for {0}: {1}" -f $App.Name, ${_})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,12 +76,12 @@ foreach ($UserProfile in $UserProfiles) {
|
||||
$Pkg = Get-AppxPackage -User $Username -Name $App.Package
|
||||
if ($Pkg) {
|
||||
$Pkg | Remove-AppxPackage -User $Username -ErrorAction Stop
|
||||
Write-Host "✔ Removed $($App.Name) from $Username" -ForegroundColor Green
|
||||
Write-Host ("✔ Removed {0} from {1}" -f $App.Name, $Username) -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "$($App.Name) not installed for $Username" -ForegroundColor Yellow
|
||||
Write-Host ("{0} not installed for {1}" -f $App.Name, $Username) -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Failed to remove $($App.Name) for $Username: $_"
|
||||
Write-Warning ("Failed to remove {0} for {1}: {2}" -f $App.Name, $Username, ${_})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,12 +93,12 @@ foreach ($App in $AppsToRemove) {
|
||||
$UserPkg = Get-AppxPackage -Name $App.Package
|
||||
if ($UserPkg) {
|
||||
$UserPkg | Remove-AppxPackage -ErrorAction Stop
|
||||
Write-Host "✔ Removed $($App.Name) from current user" -ForegroundColor Green
|
||||
Write-Host ("✔ Removed {0} from current user" -f $App.Name) -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "$($App.Name) is not installed for current user" -ForegroundColor Yellow
|
||||
Write-Host ("{0} is not installed for current user" -f $App.Name) -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Failed to remove $($App.Name) for current user: $_"
|
||||
Write-Warning ("Failed to remove {0} for current user: {1}" -f $App.Name, ${_})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user