Created
June 20, 2025 09:27
-
-
Save win2000b/995b38e19bfa49d5af609fbc5b6ae645 to your computer and use it in GitHub Desktop.
Intune Device Detect and Remediate - Windows Store App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| Type : Detection | |
| Job: Detects Microsoft 3D Viewer | |
| Run as: System | |
| Context: 64 Bit | |
| #> | |
| # Replace with part or full name of the app package | |
| $appName = "Microsoft.Microsoft3DViewer" | |
| # Check for the app in all users | |
| $appFound = Get-AppxPackage -AllUsers | Where-Object { $_.Name -like "*$appName*" } | |
| if ($appFound) { | |
| Write-Output "Appx package found: $($appFound.Name)" | |
| exit 1 | |
| } else { | |
| Write-Output "Appx package not found" | |
| exit 0 | |
| } | |
| <# | |
| Type : Remediate | |
| Job: Removes Microsoft 3D Viewer From Device if Found | |
| Run as: System | |
| Context: 64 Bit | |
| #> | |
| # Replace with part or full name of the app package | |
| $appName = "Microsoft.Microsoft3DViewer" | |
| # Get all matching packages for all users | |
| $appPackages = Get-AppxPackage -AllUsers | Where-Object { $_.Name -like "*$appName*" } | |
| foreach ($package in $appPackages) { | |
| try { | |
| Write-Output "Removing package: $($package.PackageFullName) for user: $($package.UserSID)" | |
| Remove-AppxPackage -Package $package.PackageFullName -AllUsers -ErrorAction SilentlyContinue | |
| } catch { | |
| Write-Output "Failed to remove package: $($package.PackageFullName). Error: $_" | |
| } | |
| } | |
| # Also remove provisioned package to prevent future installs | |
| $provisioned = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like "*$appName*" } | |
| foreach ($prov in $provisioned) { | |
| try { | |
| Write-Output "Removing provisioned package: $($prov.DisplayName)" | |
| Remove-AppxProvisionedPackage -Online -PackageName $prov.PackageName -ErrorAction SilentlyContinue | |
| } catch { | |
| Write-Output "Failed to remove provisioned package: $($prov.DisplayName). Error: $_" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment