Ron Shorts
asked on
Calling on vbscript and powershell experts for help
Need some help with deciphering this vbscript... this script first runs a dsquery to grab all users and DN's into a file.
Basically line 12, I'm looking to grab the DN where it builds a strNullset variable to determine if @Domain or @Domain2.org - is there a way to do this in powershell without dumping out all of the users in a file, then append later in the script?
Also looking for what line 24 actually does with the "2", and also what line 29 does... ?
Thanks experts!
Basically line 12, I'm looking to grab the DN where it builds a strNullset variable to determine if @Domain or @Domain2.org - is there a way to do this in powershell without dumping out all of the users in a file, then append later in the script?
Also looking for what line 24 actually does with the "2", and also what line 29 does... ?
Set objArgs = WScript.Arguments
If objArgs.Count < 1 Then
Wscript.Quit -1
End If
Const ADS_PROPERTY_APPEND = 3
strUserDN = objArgs(0)
Set objUser = GetObject("LDAP://" & strUserDN)
If UCase(objUser.AccountDisabled) = "FALSE" Then
strNullSet = objUser.sAMAccountName & "@Domain.org"
If InStr(UCase(strUserDN),"Domain2") Then
strNullSet = objUser.sAMAccountName & "@Domain2.org"
End If
If objUser.mail = "" Then
If objUser.userPrincipalName = strNullSet Then
Else
objUser.put "userPrincipalName", strNullSet
WScript.Echo objUser.sAMAccountName & "," & strNullSet & "," & objUser.userPrincipalName & "," & "Null"
End If
Else
If objUser.userPrincipalName = objUser.mail Then
strO365Alias = "smtp:" & objUser.sAMAccountName & "@cchs.mail.onmicrosoft.com"
If objUser.mailNickname = objUser.sAMAccountName & "2" Then
strO365Alias = "smtp:" & objUser.sAMAccountName & "2@mail"
End If
objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", Array(strO365Alias)
Else
objUser.put "userPrincipalName", objUser.mail
End If
End If
If objUser.customeAttribute1 = strNullSet Then
Else
objUser.put "customAttribute1", strNullSet
End If
objUser.SetInfo
End If
Thanks experts!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
David - this adds the samaccountname of each and appends @domain.org unless the distinguishedname flags the other OU it's it (Domain2 for example) where I have another suffix; another OU, @domain2.org it appends to if Domain2 is in the path in the DN.
ASKER
Ben - perhaps the "2" is if there is already an entry for the samaccountname, and the 2 is in case this is added twice?
I think line 29 replaces the userprincipalname with what's in the mail attribute, does that make sense?
I think line 29 replaces the userprincipalname with what's in the mail attribute, does that make sense?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"smtp:" & objUser.sAMAccountName & "2@mail" ???
It looks like you want to change domain1.org to domain2.org?