I need to remove specific SIDs<\/p>\n
Pseudo Code:<\/p>\n
#Test<\/span> if the SID exists<\/p>\n Get-LocalUser -S-1-12-1-3598938502-1280727568-3632501898-3897530764 #If<\/span> SID exists, execute the following Write-Host “Configuration complete” -ForegroundColor Blue<\/p>\n Any suggestions greatly appreciated…<\/p>","upvoteCount":5,"answerCount":8,"datePublished":"2021-09-16T15:41:42.000Z","author":{"@type":"Person","name":"raamatam","url":"https://community.spiceworks.com/u/raamatam"},"acceptedAnswer":{"@type":"Answer","text":" You might be able to do something like this (Untested)<\/p>\n I need to remove specific SIDs<\/p>\n Pseudo Code:<\/p>\n #Test<\/span> if the SID exists<\/p>\n Get-LocalUser -S-1-12-1-3598938502-1280727568-3632501898-3897530764 #If<\/span> SID exists, execute the following Write-Host “Configuration complete” -ForegroundColor Blue<\/p>\n Any suggestions greatly appreciated…<\/p>","upvoteCount":5,"datePublished":"2021-09-16T15:41:42.000Z","url":"https://community.spiceworks.com/t/trying-to-remove-sids-from-local-adminstrator-group/811376/1","author":{"@type":"Person","name":"raamatam","url":"https://community.spiceworks.com/u/raamatam"}},{"@type":"Answer","text":" Welcome<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n I understand it’s pseudo code, where are you stuck with this though?<\/p>\n
\nGet-LocalUser -S-1-12-1-61017865-1125260692-820944550-834916098<\/p>\n
\nif
\n( -eq $true)
\n{
\nRemove-LocalGroupMember -Group “Administrators” -Member “S-1-12-1-3598938502-1280727568-3632501898-3897530764”
\nRemove-LocalGroupMember -Group “Administrators” -Member “S-1-12-1-61017865-1125260692-820944550-834916098”
\n}
\n#If<\/span> SID doesn’t exist, write error message
\nElse
\n{
\nWrite-Host “not found” | Write-Error
\nExit
\n}<\/p>\n$SIDS = 'S-1-12-1-3598938502-1280727568-3632501898-3897530764', 'S-1-12-1-61017865-1125260692-820944550-834916098'\nforeach ($SID in $SIDS) {\nif\n((Get-LocalUser -SID $SID) -ne $Null)\n{\nGet-LocalUser -SID $SID | Remove-LocalGroupMember -Group \"Administrators\" -Member $SID\n}\n#If SID doesn't exist, write error message\nElse\n{\n Write-Host \"not found\" | Write-Error\n Exit\n}\n}\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2021-09-16T16:34:42.000Z","url":"https://community.spiceworks.com/t/trying-to-remove-sids-from-local-adminstrator-group/811376/3","author":{"@type":"Person","name":"titusovermyer","url":"https://community.spiceworks.com/u/titusovermyer"}},"suggestedAnswer":[{"@type":"Answer","text":"
\nGet-LocalUser -S-1-12-1-61017865-1125260692-820944550-834916098<\/p>\n
\nif
\n( -eq $true)
\n{
\nRemove-LocalGroupMember -Group “Administrators” -Member “S-1-12-1-3598938502-1280727568-3632501898-3897530764”
\nRemove-LocalGroupMember -Group “Administrators” -Member “S-1-12-1-61017865-1125260692-820944550-834916098”
\n}
\n#If<\/span> SID doesn’t exist, write error message
\nElse
\n{
\nWrite-Host “not found” | Write-Error
\nExit
\n}<\/p>\n