![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Error in script to delete AD account - Passing variable to strUser Hi all. I'm looking for some help on the following code. It's part of a larger scriopt that basically takes a username from a list containing multiple username, processes it and then delete's the user's account from Active Directory. The user's username is passed to the variable "ip". I've had the script working using a input box to take the username, but I'm struggling when trying to pass the username via another vairable. The error I get is a syntax error on the 6th line in: strUserName = ip ' Call function to delete user DeleteUser strUserName,strDomain sub DeleteUser(byval strUserName,strDomain) userDN = GetUserDN(strUserName,strDomain) set objUser = getObject("LDAP://" & userDN) set objContainer = getobject(objUser.Parent) objContainer.Delete "user","cn=" & objUser.cn end sub Function GetUserDN(byval strUserName,byval strDomain) Set objTrans = CreateObject("NameTranslate") objTrans.Init 1, strDomain objTrans.Set 3, strDomain & "\" & strUserName strUserDN = objTrans.Get(1) GetUserDN = strUserDN end function Any help greatly appreciated. N |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Error in script to delete AD account - Passing variable to strUser Sorry for multiple posts, website said there was an error posting so I re-submitted. N "nlldavies" wrote: Quote: > Hi all. I'm looking for some help on the following code. It's part of a > larger scriopt that basically takes a username from a list containing > multiple username, processes it and then delete's the user's account from > Active Directory. The user's username is passed to the variable "ip". > > I've had the script working using a input box to take the username, but I'm > struggling when trying to pass the username via another vairable. > > The error I get is a syntax error on the 6th line in: > > > strUserName = ip > > ' Call function to delete user > DeleteUser strUserName,strDomain > > sub DeleteUser(byval strUserName,strDomain) > > userDN = GetUserDN(strUserName,strDomain) > set objUser = getObject("LDAP://" & userDN) > set objContainer = getobject(objUser.Parent) > objContainer.Delete "user","cn=" & objUser.cn > > end sub > > Function GetUserDN(byval strUserName,byval strDomain) > > Set objTrans = CreateObject("NameTranslate") > objTrans.Init 1, strDomain > objTrans.Set 3, strDomain & "\" & strUserName > strUserDN = objTrans.Get(1) > GetUserDN = strUserDN > > end function > > Any help greatly appreciated. > > N |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Passing parameters to a PS script | PowerShell | |||
| problem passing args to script 'There is no script engine for file extenstion' | VB Script | |||
| Passing parameters to a cmdlet in a variable | PowerShell | |||
| Passing dynamic number of parameters to a function as a variable | PowerShell | |||
| passing variable by reference | PowerShell | |||