Intune Initial Scripts Backup

This commit is contained in:
2025-04-21 14:21:38 -04:00
commit 71764cd10f
241 changed files with 28218 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module pswindowsupdate
Import-Module pswindowsupdate
$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state
try {
if (((Get-WindowsUpdate -Title "Windows 11, version 23H2").status -eq "-D-----") -and ($scheduledTaskState.value -ne "Ready")) {
Write-Host "Update Downloaded but not scheduled"
Exit 1
}
elseif ($scheduledTaskState.value -eq "Ready") {
Write-Host "Update Downloaded and Scheduled"
Exit 0
}
Write-Host "Not Compliant"
Exit 1
}
catch {
Write-Host "Not Compliant - Catch"
Exit 1
}

View File

@@ -0,0 +1,27 @@
Import-Module PSWindowsUpdate
if ($null -eq (Get-Module PSWindowsUpdate)) {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module pswindowsupdate
Import-Module pswindowsupdate
}
$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state
if ($scheduledTaskState.value -eq "Ready") {
Write-Host "Update Already Scheduled"
Exit 0
}
else {
# Get-WindowsUpdate -MicrosoftUpdate -Title "Windows 11, version 23H2" -ScheduleJob (get-date((Get-Date).AddDays(1)) -Hour 01 -Minute 0 -Second 0) -Install -AcceptAll -AutoReboot -Verbose
# Monday's Update
Get-WindowsUpdate -MicrosoftUpdate -Title "Windows 11, version 23H2" -ScheduleJob (get-date((get-date 2025-01-23)) -Hour 01 -Minute 0 -Second 0) -Install -AcceptAll -AutoReboot -Verbose
$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state
if ($scheduledTaskState.value -eq "Ready") {
Write-Host "Update Scheduled"
Exit 0
else {
Write-Host "Update Failed to Schedule"
Exit 1
}
}
}