$cs.UsrMgr_RemoveUserFromLocalGroup
Description
Section titled “Description”Removes domain\userName from a local group. Pass . for domain to mean the local computer (it is normalized internally to the machine’s own name). The group parameter accepts either a plain group name or a SID. If the user is not currently a member of the group, the function returns silently without error.
Syntax
Section titled “Syntax”$cs.UsrMgr_RemoveUserFromLocalGroup(string domain, string userName, string group)
Parameters
Section titled “Parameters”domain (String)
Section titled “domain (String)”Domain of the user, or . for the local computer.
userName (String)
Section titled “userName (String)”Name of the user to remove from the group.
group (String)
Section titled “group (String)”The group to remove the user from. Can be a plain group name or a SID. If the user is not a member, no error is raised.
Return value
Section titled “Return value”None.
Example
Section titled “Example”Remove a domain user from the local Administrators group during cleanup:
$cs.Job_WriteLog("Removing testuser from Administrators")$cs.UsrMgr_RemoveUserFromLocalGroup('capasystems.com', 'testuser', 'Administrators')Remove a local account, using . for the domain, from a custom application group when uninstalling:
function Uninstall { $cs.Job_WriteLog("Removing capasupport from AppRemoteUsers") $cs.UsrMgr_RemoveUserFromLocalGroup('.', 'capasupport', 'AppRemoteUsers')}Remove a service account from the built-in Administrators group by SID, so the script is unaffected by locale or group renames:
$cs.Job_WriteLog("Removing svc_capaagent from the local Administrators group")$cs.UsrMgr_RemoveUserFromLocalGroup('.', 'svc_capaagent', 'S-1-5-32-544')Related functions
Section titled “Related functions”$cs.UsrMgr_AddUserToLocalGroup $cs.UsrMgr_EnumMembersOfLocalGroup