{"id":18653857,"url":"https://github.com/powershellcrack/psrebootpolicy","last_synced_at":"2025-04-11T16:33:09.436Z","repository":{"id":111449991,"uuid":"185627710","full_name":"PowerShellCrack/PSRebootPolicy","owner":"PowerShellCrack","description":"Reboot Policy using PowerShell and a modified verison of AppdeployToolkit","archived":false,"fork":false,"pushed_at":"2019-05-09T11:42:31.000Z","size":517,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-10-20T22:37:58.061Z","etag":null,"topics":["appdeploytoolkit","policy","powershell","reboot","sccm"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PowerShellCrack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-08T14:57:37.000Z","updated_at":"2023-10-20T22:37:58.921Z","dependencies_parsed_at":null,"dependency_job_id":"8383d637-fea1-4e4c-96af-cdc74885309d","html_url":"https://github.com/PowerShellCrack/PSRebootPolicy","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShellCrack%2FPSRebootPolicy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShellCrack%2FPSRebootPolicy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShellCrack%2FPSRebootPolicy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShellCrack%2FPSRebootPolicy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PowerShellCrack","download_url":"https://codeload.github.com/PowerShellCrack/PSRebootPolicy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223472750,"owners_count":17150745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appdeploytoolkit","policy","powershell","reboot","sccm"],"created_at":"2024-11-07T07:13:21.771Z","updated_at":"2024-11-07T07:13:22.380Z","avatar_url":"https://github.com/PowerShellCrack.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSRebootPolicy\nReboot Policy using PowerShell and a modified verison of AppdeployToolkit\n\n![Alt_text](https://github.com/PowerShellCrack/PSRebootPolicy/blob/master/screenshots/rebootpolicy_firstprompt.png?raw=true)\n\n![Alt_text](https://github.com/PowerShellCrack/PSRebootPolicy/blob/master/screenshots/rebootpolicy_firstballaonhide.png?raw=true)\n\n![Alt_text](https://github.com/PowerShellCrack/PSRebootPolicy/blob/master/screenshots/rebootpolicy_forcereboot.png?raw=true)\n\n# Goal\nI needed a way I can reboot a system but give the user 3 prompts before doing so at different time intevals. Also to report those responses to management. \n\n# Solution\nPSAppDeployToolkit (https://psappdeploytoolkit.com/) provided a interesting way of presenting a UI to the user when deployed via SCCM. I modified the UI slightly to achieve a look that was like a notification for the user.\n\n\n## Additional switches\n\n| Parameters          | Values     | Comments                 |\n|-------------------  |--------    |--------------------------|\n| AllowRebootPassThru  | True/False | Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered. |\n|EnableScriptTest     | True/False | Speeds up the reboot policy to 2 minute intervals between messages. Default is: $false. |\n| IgnoreRebootCheck    | True/False  | Force the system to go through the reboot scenario no matter what. Use in conjunction with EnableScriptTest to allow quicker test of the full check. Default is: $false. |\n| ForcePendingReboot   | True/False  | Force the system reboot if a pending reboot is detected on system no matter the day it rebooted in the past. Ignores the RebootIntervalDays check as well. Default is: $false. |\n| ScriptDisabled       | True/False  | Disables the script from running. Also can be switched by seeting a registry key in HKLM\\SOFTWARE\\Policies\\RebootPolicy with a key of DisableRebootPolicy of 1. Can be controlled by GPO. Default is: $false. |\n| RebootIntervalDays      | 1,3,5,7,14 | Compares the last reboot date timestamp to number specified; Default is: 7 days |\n| MaxReboots           | integer      | Doesn't allow script to reboot the system more than this number; Safety incase system need multple reboots; Default is: 2 times |\n\n## Main Logging\nScript logs entries into the registry under `HKLM:SOFTWARE\\Policies\\\u003cCompany name\u003e\\Logging`\n\n| Entry                | Values                | Comments                 |\n|-------------------   |--------               |--------------------------|\n| ScriptVersion        |  Version              |                          |\n| ScriptLastRunTime    | Date                  |\n| ScriptLastLogDir     | \u003cSee RunLog section\u003e\n| PolicyRunCount       | Counter               | Count how many times the script has ran|\n| DisableRebootPolicy  | 0 or 1                | Exit script if set to be disabled and exit with 0\n| RebootAttemptCounter | Counter | Check if the reboot counter has hit the max if so kill script\n| ErrorDisabled        | 0 or 1                | Triggered set if max reboot is reached\n| RebootCountTotal     | Counter               | Record total times script has rebooted system\n\n## Run Logging\nThere is a sub keys to record every instance and acton when ran using julian time format. It is located here: `HKLM:SOFTWARE\\Policies\\\u003cCompany name\u003e\\Logging\\RunLog-\u003cjulianDate\u003e`\n\n| Entry               | Values     | Comments                 |\n|-------------------  |--------    |--------------------------|\n| LastResult          | \u003cStatus\u003e   | Status are: Running,Disabled,ErrorDisabled,ForcedReboot-Prompt,PendingReboot-Prompt,RequiredReboot-Prompt,NoReboot-Needed,Rebooted-NoUser |\n| PendingRebootWhenRan | 0 or 1                | Logs if Pending Reboot key exists |\n| SleepRandomKey      | Random 0-300 | logs random number for first use, always use this key for this instance (1 to 5 minutes) |\n| LastRebootDate      | Date           | Logs last time the system rebooted |\n| PolicyStartTime     | Date           | Logs when script started |\n| UserLoggedinWhenRan | username       | Logs if a user is logged in (actively or inactively) |\n| PolicyEndTime       | Date           | Logs when script ends |\n|PromptActionResponse1 | Hide/Reboot   | Logs reponse for first prompt |\n|PromptActionResponse2 | Hide/Reboot   | Logs reponse for second prompt |\n\n## GPO Policy\nScript can also be controlled by a GPO policy. Key will be located here: `HKLM:SOFTWARE\\Policies\\RebootPolicy`\n\n| Entry               | Values     | Comments                 |\n|-------------------  |--------    |--------------------------|\n| DisableRebootPolicy  | 0/1 | Disabled the script entirely if set to 1, no matter what runs it |\n\n\n## Status \nHere are meanings of the status messages \n\n| Value                  | Meaning               |\n|------------------------|--------------------------|\n| Running                | Script is running |\n| Disabled               | Script is disabled either by GPO or ScriptDisabled parameter |\n| ErrorDisabled          | Script Errored because it rebooted system mor than MaxReboots |\n| ForcedReboot-Prompt    | Script parameter $IgnoreRebootCheck is triggered and prompted user |\n| PendingReboot-Prompt   | Script detected a pending reboot is required and prompted user |\n| RequiredReboot-Prompt  | Script detected a reboot is required based last reboot is greater than RebootIntervalDays and prompted user |\n| NoReboot-Needed        | Script detected no reboot required and notified user |\n| Rebooted-NoUser        | Script detected no user is logged in and it will reboot the system with no prompt |\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershellcrack%2Fpsrebootpolicy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowershellcrack%2Fpsrebootpolicy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershellcrack%2Fpsrebootpolicy/lists"}