From ac4b6e070024b1cd7112ed18d54f3a404b650020 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 22 Aug 2024 23:12:11 +0200 Subject: [PATCH] Remove user profile of OneShot user --- scripts/Common/Scripts/Operations.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Common/Scripts/Operations.ps1 b/scripts/Common/Scripts/Operations.ps1 index 47b722a1..8720953e 100644 --- a/scripts/Common/Scripts/Operations.ps1 +++ b/scripts/Common/Scripts/Operations.ps1 @@ -91,7 +91,10 @@ $null = New-Module { #> function Disable-OneShotListener { Unregister-ScheduledTask -Confirm:$false $oneShotTaskName; - Remove-LocalUser (& $getUserName); + $user = Get-LocalUser (& $getUserName); + [string] $sid = $user.SID; + Remove-LocalUser $user; + Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance; } <#