Created
May 28, 2019 10:29
-
-
Save Stephanevg/6d274bd762aa29bed820c0b94dd30e93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[String]$UserSID = 'S-1-5-21-3890033740-644365979-2086776761-1001', | |
[String]$GroupName | |
) | |
If($UserSID){ | |
$Response.SetContentType('text/plain') | |
#$Body = [System.Web.HttpUtility]::UrlDecode($Request.BodyString) | |
$Response.Send(($Request.BodyString)) | |
<# | |
$Body = [System.Web.HttpUtility]::UrlDecode($Request.BodyString) | |
$Data = @{} | |
$Body.split('&') | %{ | |
$part = $_.split('=') | |
$Data.add($part[0], $part[1]) | |
} | |
$result = $Data | ConvertTo-Json | |
$Response.Send(($result | ConvertFrom-Json)) | |
#> | |
<# | |
$AdminGroup = Get-LocalGroup -Name $GroupName | |
$LocalUser = Get-LocalUser -SID $UserSID | |
If($LocalUser){ | |
Write-Verbose "Removing user $($LocalUser.FullName)" | |
Try{ | |
Remove-LocalGroupMember -Group $AdminGroup -Member $LocalUser -ErrorAction Stop | |
}Catch{ | |
return "Successfully removed user with SID: $($UserSID)" | |
} | |
} | |
#> | |
}Else{ | |
Return "No User found with sid $($UserSID)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment