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
      }
}
}