From f338fabe0cb8ba8680a4f0b4b27c315498fe5f53 Mon Sep 17 00:00:00 2001 From: silversword411 Date: Fri, 17 May 2024 13:43:48 -0400 Subject: [PATCH 1/4] New Community Script: Reboot --- community_scripts.json | 14 ++++++++++++++ scripts/Win_Reboot.ps1 | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 scripts/Win_Reboot.ps1 diff --git a/community_scripts.json b/community_scripts.json index c856ce32..490359a9 100644 --- a/community_scripts.json +++ b/community_scripts.json @@ -1028,6 +1028,20 @@ ], "default_timeout": 30 }, + { + "guid": "5d905886-9eb1-4129-8b81-a013f842eb24", + "filename": "Win_Reboot.ps1", + "submittedBy": "https://github.com/silversword411", + "name": "Reboot/Restart Computer", + "description": "Reboots/Restarts the computer with an optional wait time before restarting.", + "syntax": "[-wait ]", + "shell": "powershell", + "category": "TRMM (Win):Other", + "supported_platforms": [ + "windows" + ], + "default_timeout": 30 + }, { "guid": "f396dae2-c768-45c5-bd6c-176e56ed3614", "filename": "Win_Power_RestartorShutdown.ps1", diff --git a/scripts/Win_Reboot.ps1 b/scripts/Win_Reboot.ps1 new file mode 100644 index 00000000..9f201c3c --- /dev/null +++ b/scripts/Win_Reboot.ps1 @@ -0,0 +1,28 @@ +<# +.SYNOPSIS + Restarts the computer with an optional wait time (in seconds) before restarting. + +.DESCRIPTION + This script restarts the computer forcefully. + +.PARAMETER Wait + Specifies the number of seconds to wait before restarting the computer. + +.EXAMPLE + -Wait 60 + Waits for 60 seconds and then restarts the computer. + +.NOTES + v1.0 5/17/2024 Created by silversword411 +#> + +param( + [int]$Wait +) + +if ($Wait) { + Restart-Computer -Force -Delay $Wait +} +else { + Restart-Computer -Force +} From c426a5a5b6387cb3d3f0899b51b591566b4ecb07 Mon Sep 17 00:00:00 2001 From: silversword411 Date: Fri, 17 May 2024 13:58:08 -0400 Subject: [PATCH 2/4] derp...forgot a new guid --- community_scripts.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_scripts.json b/community_scripts.json index 490359a9..864b1a02 100644 --- a/community_scripts.json +++ b/community_scripts.json @@ -1029,7 +1029,7 @@ "default_timeout": 30 }, { - "guid": "5d905886-9eb1-4129-8b81-a013f842eb24", + "guid": "5bc815a0-d349-416f-8c3d-ac499d4da2e8", "filename": "Win_Reboot.ps1", "submittedBy": "https://github.com/silversword411", "name": "Reboot/Restart Computer", From 79af8f0bb500cd6b05685be5d16d62e4498e0434 Mon Sep 17 00:00:00 2001 From: silversword411 Date: Thu, 23 May 2024 11:56:17 -0400 Subject: [PATCH 3/4] Fixing reboot script and timeouts --- community_scripts.json | 2 +- scripts/Win_Reboot.ps1 | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/community_scripts.json b/community_scripts.json index 864b1a02..af94a372 100644 --- a/community_scripts.json +++ b/community_scripts.json @@ -1040,7 +1040,7 @@ "supported_platforms": [ "windows" ], - "default_timeout": 30 + "default_timeout": 86400 }, { "guid": "f396dae2-c768-45c5-bd6c-176e56ed3614", diff --git a/scripts/Win_Reboot.ps1 b/scripts/Win_Reboot.ps1 index 9f201c3c..53ae638e 100644 --- a/scripts/Win_Reboot.ps1 +++ b/scripts/Win_Reboot.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Restarts the computer with an optional wait time (in seconds) before restarting. + Reboots/Restarts the computer with an optional wait time before restarting. Max wait 24hrs .DESCRIPTION This script restarts the computer forcefully. @@ -21,7 +21,8 @@ param( ) if ($Wait) { - Restart-Computer -Force -Delay $Wait + Sleep $Wait + Restart-Computer -Force } else { Restart-Computer -Force From 83b637b07ef6e6c0071478937729341f53207ccf Mon Sep 17 00:00:00 2001 From: silversword411 Date: Wed, 29 May 2024 09:44:10 -0400 Subject: [PATCH 4/4] Fix reboot script --- scripts/Win_Reboot.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/Win_Reboot.ps1 b/scripts/Win_Reboot.ps1 index 53ae638e..6ea23c76 100644 --- a/scripts/Win_Reboot.ps1 +++ b/scripts/Win_Reboot.ps1 @@ -13,7 +13,7 @@ Waits for 60 seconds and then restarts the computer. .NOTES - v1.0 5/17/2024 Created by silversword411 + v1.0 5/17/2024 Created by silversword411 and dinger1986 #> param( @@ -21,8 +21,7 @@ param( ) if ($Wait) { - Sleep $Wait - Restart-Computer -Force + shutdown -r -t $Wait } else { Restart-Computer -Force