From 141b8290da269e2d4e638e29f34c4c8c3fa41154 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 19 Aug 2024 01:37:14 +0200 Subject: [PATCH] Allow registering reboots for users --- scripts/Windows/Scripts/PowerManagement.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/Scripts/PowerManagement.ps1 b/scripts/Windows/Scripts/PowerManagement.ps1 index 3c9b332a..41484186 100644 --- a/scripts/Windows/Scripts/PowerManagement.ps1 +++ b/scripts/Windows/Scripts/PowerManagement.ps1 @@ -153,12 +153,15 @@ $null = New-Module { #> function Restart-Intermediate { param( - [switch] $DefaultUser + [Parameter(ParameterSetName="Default", Mandatory)] + [switch] $DefaultUser, + [Parameter(ParameterSetName="Current", Mandatory)] + [switch] $CurrentUser ) $register = { param($UserKey) Register-Setup @PSBoundParameters; }; - if ($DefaultUser) { + if ($DefaultUser.ToBool()) { Edit-DefaultUserKey { param( [RegistryKey] $Key @@ -166,6 +169,8 @@ $null = New-Module { & $register $Key; } + } elseif ($CurrentUser.ToBool()) { + & $register (Get-Item HKCU:\); } else { & $register; }