Guest User

Untitled

a guest
Dec 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Set-StrictMode -Version 'Latest'
  2.  
  3. $AdObj = New-Object System.Security.Principal.NTAccount($User)
  4. $strSID = $AdObj.Translate([System.Security.Principal.SecurityIdentifier])
  5. $Sid = $strSID.Value
  6. Assert-NotNull $Sid
  7.  
  8. $Path = "Registry::HKEY_USERS$SidEnvironment"
  9.  
  10. $Property = Get-ItemProperty $Path -Name $Variable -ErrorAction Ignore
  11. if($Property) {
  12. Write-Warning "Removing $Variable property on path $path from user $User"
  13. Remove-ItemProperty $Path -Name $Variable
  14. }else{
  15. Write-Host "No such Variable exists"
  16. }
Add Comment
Please, Sign In to add comment