<# Author: Gabe Kerntke Company: UFS LLC Date: 03-12-2025 .Synopsis .Modified 2025-03-12 (GabeK) - Original script created #> # Variables # $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem # Functions # # Start Script # If ($osInfo.ProductType -ne "1") { $Date = Get-Date -DisplayHint Date $GetLastDay = New-Object DateTime($Date.Year, $Date.Month, [DateTime]::DaysInMonth($Date.Year, $Date.Month)) $LastDay = $GetLastDay #.ToString("dddd, MMMM d, yyyy") $SecondLastDay = $LastDay.AddDays(-1) $ThirdLastDay = $LastDay.AddDays(-2) $ForthLastDay = $LastDay.AddDays(-3) $FifthLastDay = $LastDay.AddDays(-4) $SixthLastDay = $LastDay.AddDays(-5) $SevenLastNight = $LastDay.AddDays(-6) $Array = @( $LastDay, $SecondLastDay, $ThirdLastDay, $ForthLastDay, $FifthLastDay, $SixthLastDay, $SevenLastNight ) $excludeValues = "Saturday", "Sunday" $filteredArray = $array | Where-Object { $_.DayOfWeek -notin $excludeValues } If ($Date -in $filteredArray) { Write-Host "do not reboot" Exit } Else { Write-Host "can reboot" #Restart-Computer -Force } } Else { Write-Host "Device is not a server, exiting script." } # End Script #