Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set-StrictMode -Version 'Latest'
- $AdObj = New-Object System.Security.Principal.NTAccount($User)
- $strSID = $AdObj.Translate([System.Security.Principal.SecurityIdentifier])
- $Sid = $strSID.Value
- Assert-NotNull $Sid
- $Path = "Registry::HKEY_USERS$SidEnvironment"
- $Property = Get-ItemProperty $Path -Name $Variable -ErrorAction Ignore
- if($Property) {
- Write-Warning "Removing $Variable property on path $path from user $User"
- Remove-ItemProperty $Path -Name $Variable
- }else{
- Write-Host "No such Variable exists"
- }
Add Comment
Please, Sign In to add comment