Deleting users from an OU - Richard Mueller [MVP] |
30-May-07 02:38:08
|
The parameters of the Delete method need to be in quotes, separated by a
comma. The syntax should be:
objOU.Delete "user", "cn=047-c110-01"
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
-- |
 |
| |
Deleting users from an OU - Jeremy Schubert |
30-May-07 07:46:46
|
Thanks Richard. I tried your suggestion before posting but it didn't work.
But now it is. It's a long, sordid story...
I used Excel to masage together my user names and the paramters. Then I
realized I needed double quotation marks around the parameters. I was able
to use the replace function in Notepad to add most of the double quotes, but
I couldn't figure out how to 'say' add double quotes to the end of each line
(in Notepad). Word let me use ^p in the replace function so I could replace
^p with ^p". But then when I ran the script, the computer wouldn't
recongnize the double quotes produced by Word. So I finally figured out to
use the Word replace function to add ZZ to the end of each line. Then, in
Notepad, I was able to replace the ZZ with double quotes created by Notepad
and all worked well. Then I cursed and said to myself, "The accounts
already existed. Why didn't I just export them to a txt file instead of an
Excel file and massaging data from there!" Next time... |
 |
| |
Deleting users from an OU - Richard Mueller [MVP] |
30-May-07 08:08:40
|
I'm not sure what your code looks like, but the Delete method parameters can
be variables with string values assigned. For example, I would expect code
similar to the following to work:
strClass = "user"
strUserCN = objCell(intRow, intCol).Value
objOU.Delete strClass, "cn=" & strUserCN
and, if objCell(intRow, intCol).Value is equal to "cn=047-c110-01", then you
could use:
objOU.Delete strClass, strUserCN
The reason the first version did not work is that without the quotes, the
interpreter decided that user and cn=047-c110-01 were both variable names
(with blank values). The important thing is that you got the program to
work. |
 |
| |
Deleting users from an OU - Jeremy Schubert |
30-May-07 08:53:19
|
Thank you again Richard. Going on what you have here, if I wanted to add a
profile path to all users, I could do something like
strUserCN=objCell(intRow,2).Value
objUser.Put "profilePath", \\server\profile.man$
and just have it loop til it comes to an empty cell? (assuming I have the
values for CN in column 2)
Jeremy |
 |
| |