Remove user profile of OneShot user

This commit is contained in:
Manuel Thalmann 2024-08-22 23:12:11 +02:00
parent 56463a4e30
commit ac4b6e0700

View file

@ -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;
}
<#