cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Mlacombe
Engaged Sweeper III
Hi,

Can someone assist me with setting some AD attributes using custom actions? I've got the below script, which, by itself, works well at setting the city and state attribute. How can I take this script and apply it to Lansweeper? I understand where to save the file, and where to set up the action within Lansweeper, I just need some syntax help. For example, at the top of my script, you'll see that it specifies the user that I wish to modify. I would like to change this so that whichever user I have selected in Lansweeper will be the user that this action gets applied to. (Ideally, so I can run this action against multiple users at once and streamline our Active Directory cleanup.) Any help would be greatly appreciated!


Set objUser = GetObject _
("LDAP://cn=User1,ou=MyUsers,ou=MySite,dc=MyDomain")

strCity = InputBox("Please enter the name of the city:", _
"Active Directory City Attribute")
If strCity = "" Then
Wscript.Quit
End If

strState = InputBox("Please enter the name of the state:", _
"Active Directory State Attribute")
If strState = "" Then
Wscript.Quit
End If


objUser.Put "l", strCity
objUser.Put "st", strState
objUser.SetInfo

4 REPLIES 4
Mlacombe
Engaged Sweeper III
Awesome, it looks like that did the trick.

Thank you for the help!
Hemoco
Lansweeper Alumni
You are missing a space after .vbs

{actionpath}ModCityState.vbs "{cn}"
Mlacombe
Engaged Sweeper III
Ok, so the script now looks like this:

struser= WScript.Arguments(0)
Set objUser = GetObject("LDAP://" & struser)

strCity = InputBox("Please enter the name of the city:", _
"Active Directory City Attribute")
If strCity = "" Then
Wscript.Quit
End If

strState = InputBox("Please enter the name of the state:", _
"Active Directory State Attribute")
If strState = "" Then
Wscript.Quit
End If


objUser.Put "l", strCity
objUser.Put "st", strState
objUser.SetInfo


The script has been moved to \\myserver\c$\Program Files (x86)\Lansweeper\Actions

And the action path looks like this:

{actionpath}ModCityState.vbs"{cn}"


But when I run it, I get the following error:

"File Not Found.

\\myserver\lansweeper$\ModCityState.vbs"CN=User1,OU=Users,OU=Site1,DC=Domain"

Note that I replaced the actual AD values with User1, Site1, and Domain in this case.
Hemoco
Lansweeper Alumni
Please have a look at the built-in user actions in the Lansweeper web console under Configuration\Website Management\User Pages and the related scripts found in Program Files (x86)\Lansweeper\Actions on your Lansweeper server. You should include the following in your script and add the {cn} parameter to your custom action to pass the user to the script:
struser= WScript.Arguments(0)
Set objUser = GetObject("LDAP://" & struser)

Note that there is no built-in functionality in Lansweeper for applying custom actions to multiple users at once.