Jan 24 2024 01:56 AM
Hello everyone,
I've encountered an issue with a script that performs flawlessly when executed manually on the device. However, when running the same script via Intune, it reports success but doesn't effectively achieve its goal. Despite restarting the device, the problem persists. The script is designed to remove personal Teams on Windows 11 devices. Any insights or assistance in resolving this discrepancy would be greatly appreciated. What do I need to to the script to get it to work
Here is the script:
$MSTeams = "MicrosoftTeams"
$WinPackage = Get-AppxPackage | Where-Object {$_.Name -eq $MSTeams}
$ProvisionedPackage = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $WinPackage }
If ($null -ne $WinPackage)
{
Remove-AppxPackage -Package $WinPackage.PackageFullName
}
If ($null -ne $ProvisionedPackage)
{
Remove-AppxProvisionedPackage -online -Packagename $ProvisionedPackage.Packagename
}
$WinPackageCheck = Get-AppxPackage | Where-Object {$_.Name -eq $MSTeams}
$ProvisionedPackageCheck = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $WinPackage }
If (($WinPackageCheck) -or ($ProvisionedPackageCheck))
{
throw
}
Jan 24 2024 04:32 AM
SolutionJan 24 2024 04:32 AM
Solution