Created
April 15, 2026 11:28
-
-
Save HighLibrarian/0700501c513afdef92e0f3f00cb08ec4 to your computer and use it in GitHub Desktop.
Autopilot Post OOBE patching
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
| $logDirectory = "C:\Windows\Logs\Software\IntunePlatformScripts" | |
| $logPath = (New-Item "$logDirectory\post-oobe-patching.log" -ItemType File -Force).FullName | |
| Start-Transcript -Path $logPath -Force | |
| Write-Information "Starting Windows Update." -InformationAction Continue | |
| try | |
| { | |
| Start-Process -FilePath "USOClient.exe" -ArgumentList "StartInteractiveScan" -NoNewWindow -Wait | |
| Start-Sleep -Seconds 15 | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-windows-ok" -ItemType File -Force | |
| Write-Information "ok" -InformationAction Continue | |
| } | |
| catch | |
| { | |
| Write-Information "Windows Update check failed: $($_.Exception.Message)" -InformationAction Continue | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-windows-nok" -ItemType File -Force | |
| Write-Information "nok" -InformationAction Continue | |
| } | |
| Write-Information "Starting windows store app updates." -InformationAction Continue | |
| try | |
| { | |
| Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-store-ok" -ItemType File -Force | |
| Write-Information "ok" -InformationAction Continue | |
| } | |
| catch | |
| { | |
| Write-Information "Store app update scan failed: $($_.Exception.Message)" -InformationAction Continue | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-store-nok" -ItemType File -Force | |
| Write-Information "nok" -InformationAction Continue | |
| } | |
| Write-Information "Starting Microsoft Defender for Endpoing definition updates" -InformationAction Continue | |
| try | |
| { | |
| Update-MpSignature -verbose | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-mde-ok" -ItemType File -Force | |
| Write-Information "ok" -InformationAction Continue | |
| } | |
| catch | |
| { | |
| Write-Information "MDE update failed: $($_.Exception.Message)" -InformationAction Continue | |
| $null = new-item -Path "$logDirectory\post-oobe-patching-mde-nok" -ItemType File -Force | |
| Write-Information "nok" -InformationAction Continue | |
| } | |
| Stop-Transcript | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment