amidaware / community-scripts

A curated list of powershell, python, and batch scripts for use in TacticalRMM or anywhere!
MIT License
119 stars 82 forks source link

New Community Script: Reboot #235

Closed silversword411 closed 4 months ago

silversword411 commented 4 months ago

Please merge if this looks good thx!

dinger1986 commented 4 months ago

testwait

Doesnt work for me, changed afew things but not passing $Wait correctly

silversword411 commented 4 months ago

A 120 second wait on a 90 second killed script definitely won't work 😂

Probably need to update timeout to 12hrs or something crazy or agent is going to kill it while ps is waiting.

dinger1986 commented 4 months ago

changed timeout to 300 seconds and wait to 120 seconds and still get the same

silversword411 commented 4 months ago

ChatGPT failed me... -wait on Restart-Computer also requires other flags. Let's just ps sleep x and then run it....with an expanded script timeout.

Actually tested this time.

dinger1986 commented 4 months ago

Id just do it

param(
    [int]$Wait
)

if ($Wait) {
    shutdown -r -t $Wait
}
else {
    Restart-Computer -Force
}
silversword411 commented 4 months ago

Id just do it

Works for me! :)