Skip to content

Commit 859b44e

Browse files
authored
Update Reboot.ps1
1 parent 1affbe7 commit 859b44e

File tree

1 file changed

+7
-6
lines changed
  • Intune_Scripts/AutopilotV2/RenameDevice/Win32App_Content

1 file changed

+7
-6
lines changed

Intune_Scripts/AutopilotV2/RenameDevice/Win32App_Content/Reboot.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Date: [31-Aug-2024]
2424
Version: 1.0
2525
2626
.EXAMPLE
27-
PS C:\> .\Reboot.ps1
27+
PS C:\> .\Handle-Reboot.ps1
2828
This command executes the script, logging its progress, handling the reboot and notification tasks, and conditionally rebooting the device based on user input.
2929
3030
#>
@@ -56,7 +56,7 @@ if (-not(Test-Path $LogFilePath)) {
5656
Try {
5757
# Create the log file and log the script start.
5858
New-Item -path $LogFilePath -Itemtype "File" -force -erroraction "stop" | Out-Null
59-
Write-Log -Level "Info" -Message "Script execution started."
59+
Write-Log -Level "Info" -Message "Script execution starts here."
6060
Write-Log -Level "Info" -Message "Log file created at '$($LogFilePath)'."
6161
}
6262
Catch {
@@ -95,7 +95,6 @@ Write-Log -Level "Info" -Message "The scheduled task : $($RebootNotificationSchd
9595
do {
9696
$taskStatus = (Get-ScheduledTask -TaskName $RebootNotificationSchdTaskName).State
9797
Write-Log -Level "Info" -Message "Waiting for the scheduled task to complete. Current status: $taskStatus."
98-
Start-Sleep -Seconds 5
9998
} while ($taskStatus -eq "Running")
10099

101100
Write-Log -Level "Info" -Message "The scheduled task : $($RebootNotificationSchdTaskName) has completed."
@@ -108,12 +107,14 @@ if (Test-Path -Path $DetectionTagFilePath) {
108107

109108
# Log user confirmation and reboot the device.
110109
Write-Log -Level "Info" -Message "The user clicked on 'Yes' button."
111-
Write-Log -Level "Info" -Message "Hence rebooting the device."
112-
Write-Log -Level "Info" -Message "Script execution ended."
110+
Write-Log -Level "Info" -Message "Script execution ends here."
111+
Write-Log -Level "Info" -Message "Sleeping for 5 mins."
112+
Start-Sleep -Seconds 300
113+
Write-Log -Level "Info" -Message "Rebooting the device."
113114
Restart-Computer -Force
114115
}
115116
else {
116117
# Log that the user declined the reboot, and end the script without rebooting.
117118
Write-Log -Level "Info" -Message "The user clicked on 'No' button so no reboot will happen."
118-
Write-Log -Level "Info" -Message "Script execution ended."
119+
Write-Log -Level "Info" -Message "Script execution ends here."
119120
}

0 commit comments

Comments
 (0)