Remove user profile of OneShot user

This commit is contained in:
Manuel Thalmann 2024-08-22 23:12:11 +02:00
parent 1b3b376cce
commit e25fdccf23

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