Hi I was curious if anyone could help me figure out how to have my script below read a single column .csv file and use each rows content as the distinguished name in the script (there are two places it needs to be). So that the script would read the first line in the .csv file and use its contents as the distinguished name then run the script and then loop back up and read the next row and run its through the script so on and so forth until there was no more names.
On Error Resume Next
Const ADS_PROPERTY_DELETE = 4
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Set objUser = GetObject _
("LDAP://CN=Doe\, John,OU=Users OU,DC=domain,DC=com")
arrMemberOf = objUser.GetEx("memberOf")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "This account is not a member of any security groups."
WScript.Quit
End If
For Each Group in arrMemberOf
Set objGroup = GetObject("LDAP://" & Group)
objGroup.PutEx ADS_PROPERTY_DELETE, _
"member", Array("CN=Doe\, John,OU=Users OU,DC=domain,DC=com")
objGroup.SetInfo
Next
On Error Resume Next
Const ADS_PROPERTY_DELETE = 4
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Set objUser = GetObject _
("LDAP://CN=Doe\, John,OU=Users OU,DC=domain,DC=com")
arrMemberOf = objUser.GetEx("memberOf")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "This account is not a member of any security groups."
WScript.Quit
End If
For Each Group in arrMemberOf
Set objGroup = GetObject("LDAP://" & Group)
objGroup.PutEx ADS_PROPERTY_DELETE, _
"member", Array("CN=Doe\, John,OU=Users OU,DC=domain,DC=com")
objGroup.SetInfo
Next