MJPollard 0 Posted April 24, 2010 What's wrong with the following snippet: Dim $UserGroup, $UserName $UserGroup = "Guests" $UserName = "xGuest" ;Add User to group $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $UserGroup) $objUser = ObjGet("WinNT://" & @ComputerName & "/" & $UserName) If $objGroup.IsMember($UserName) = False Then $objGroup.Add($objUser.ADsPath) EndIf ; Runtime error on the following line with the error msg below ; $objGroup.Add($objUser.ADsPath) ; Error: The requested action with this object has failed. Share this post Link to post Share on other sites
water 2,388 Posted April 25, 2010 (edited) Do you want to add a local or a domain user to the group?For domain user please see this link. Edited April 25, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
MJPollard 0 Posted April 25, 2010 (edited) Do you want to add a local or a domain user to the group?For domain user please see this link.It is a local account. The thing is the thread you link to claims that it works for a local account. While the variables have a different name and I have a check, as far as I can tell my instruction to add the user to the group is exactly the same.The other part that bothers me is that when I check the values as I step through this $objGroup and $objUser appear to be valueless but $objUser.ADsPath shows the expected information. Edited April 25, 2010 by MJPollard Share this post Link to post Share on other sites
MJPollard 0 Posted April 25, 2010 What's wrong with the following snippet: Dim $UserGroup, $UserName $UserGroup = "Guests" $UserName = "xGuest" ;Add User to group $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $UserGroup) $objUser = ObjGet("WinNT://" & @ComputerName & "/" & $UserName) If $objGroup.IsMember($UserName) = False Then $objGroup.Add($objUser.ADsPath) EndIf ; Runtime error on the following line with the error msg below ; $objGroup.Add($objUser.ADsPath) ; Error: The requested action with this object has failed. This is a corrected version that appears to be working. I've only included the instructions. The check was changed to 'If Not' and the .IsMember was changed to $objUser.ADsPath. $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $UserGroup & ",group") $objUser = ObjGet("WinNT://" & @ComputerName & "/" & $UserName & ",user") If Not $objGroup.IsMember($objUser.AdsPath) Then $objGroup.Add ($objUser.AdsPath) EndIf Share this post Link to post Share on other sites