http://www.perlmonks.org?node_id=450392
softworkz has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks, I've been in the windoze prison for some time now and I'm looking to escape! I have been forced to create a VBscript that creates AD accounts and the quickest way I could find a solution was to use VBscript (hence the windoze prison). Is there a way to do the same thing but in Perl instead? I only included the code that actually creates the accounts (this is the piece I'd rather have in Perl), any examples would be helpful, thanks!!
'------------------------------------------------------ ' Add piece to create users here Const ADS_PROPERTY_UPDATE = 2 Const ADS_PROPERTY_APPEND = 3 'Bind to OU Where new User will be placed (domain users) '----------------------------- Set objOU = GetObject("LDAP://OU=Domain Users,DC=HEADQUARTERS,DC=YOURC +OMPANY,DC=com") 'Create New User and set specific information '-------------------------------------------------- Set objUser = objOU.Create("User","cn=" & strName) objUser.Put "sAMAccountName", strNetId objUser.SetInfo objUser.AccountDisabled = False objUser.SetInfo objUser.SetPassword strPass objUser.Put "mail", strNetId & "@YOURCOMPANY.com" objUser.Put "givenName",strFName objUser.Put "sn", strLName objUser.Put "displayName",strName objUser.Put "userPrincipalName",strNetId & "@YOURCOMPANY.com" objUser.SetInfo ' Add that user to their respective global security group Set objGroup = GetObject("LDAP://cn=" & strUserDir & ",OU=Domain Users +,DC=HEADQUARTERS,DC=YOURCOMPANY,DC=com") objGroup.PutEx ADS_PROPERTY_APPEND, "member", _ Array("cn=" & strName & ",ou=domain users,dc=HEADQUARTERS,dc=YOURC +OMPANY,dc=com") objGroup.SetInfo ' Add that user to general users group Set objGroup = GetObject("LDAP://cn=General,cn=users,DC=HEADQUARTERS,D +C=YOURCOMPANY,DC=com") objGroup.PutEx ADS_PROPERTY_APPEND, "member", _ Array("cn=" & strName & ",ou=Domain Users,dc=HEADQUARTERS,dc=YOURC +OMPANY,dc=com") objGroup.SetInfo '--------------------------------------------------