Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $archour = Read-Host -Prompt 'What hour, in 24 hour format, do you want to reboot?'
- $arcminu = Read-Host -Prompt 'What minute do you want to reboot?'
- $maxRetries = 9999999; $retryCount = 0; $completed = $false
- while (-not $completed) {
- Clear-Variable -Name "TimeNow" -EA SilentlyContinue
- Clear-Variable -Name "TimeDial" -EA SilentlyContinue
- $TimeNow = (Get-Date).ToString('HH:mm')
- $TimeDial = $TimeNow.split(':')
- if ($TimeDial[0] -gt $archour) {
- if ($TimeDial[1] -gt $arcminu){
- Restart-Computer -ComputerName $env:COMPUTERNAME -Force
- $completed = $true
- }
- }
- else {
- if ($retryCount -ge $maxRetries) {
- } else {
- Write-Verbose "It is not time yet, trying again in 60 seconds."
- Start-Sleep '60'
- $retryCount++
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement