refactor(scripts): optimize system remediation and M365 export scripts
- teams: harden Classic Teams removal, protect New Teams, and clean HKU run keys - dotnet: add bootstrapper EXE uninstall support and remove orphaned 3.1.* folders - teams: add MSIX package targeting and version parsing for vulnerable New Teams builds - m365: improve Graph SDK export speed, reuse sessions, and add null-safe handling
This commit is contained in:
1 parent
4fd95b76d6
commit
5ef82842f2
19 files changed
+1651
-1268
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Enrolls the endpoint into Microsoft Intune / MDM.
|
||||
.DESCRIPTION
|
||||
Triggers the Windows auto-enrollment process via deviceenroller.exe.
|
||||
Intended for company-owned endpoints.
|
||||
#>
|
||||
|
||||
# Prompt for confirmation (case-insensitive)
|
||||
Write-Host "WARNING: This script will enroll the current device into MDM." -ForegroundColor Red
|
||||
Write-Host "This is meant for company-owned devices only." -ForegroundColor Red
|
||||
$answer = Read-Host "Do you want to continue? (Y/N)"
|
||||
|
||||
if ($answer -notmatch '^[Yy](es)?$') {
|
||||
Write-Host "Exiting script — Device will not be enrolled into MDM." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "Triggering Intune MDM enrollment..." -ForegroundColor Cyan
|
||||
|
||||
try {
|
||||
# Launch deviceenroller and wait for command trigger completion
|
||||
$process = Start-Process -FilePath "$env:SystemRoot\System32\deviceenroller.exe" `
|
||||
-ArgumentList "/c /AutoEnrollMDM" `
|
||||
-Wait `
|
||||
-PassThru `
|
||||
-NoNewWindow
|
||||
|
||||
if ($process.ExitCode -eq 0) {
|
||||
Write-Host "MDM AutoEnrollment command initiated successfully." -ForegroundColor Green
|
||||
Write-Host "Note: Enrollment processing occurs asynchronously in the background." -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "deviceenroller.exe exited with code: $($process.ExitCode)" -ForegroundColor Red
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Failed to launch deviceenroller.exe: $_" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Reference in new issue
Block a user