search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
.NET Framework GroupsView
Deployment Server
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Micro Porting
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Vista Compatibility
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Vsnet Debugging
Windows Powershell
Windowsce Embedded Vc
Xml
Xsl

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Application Development
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Scripting Visual Basicscript Posts  Ask A New Question 

Deleting users from an OU - Jerem

Wednesday, May 30, 2007 2:13 PM

When I run the following script, I get an error message: Line 2, Char 19,
Exprected end of statement.
Can anyone help me out please?

Set objOU =
GetObject("LDAP://ou=047UDiploma,ou=047USchool,ou=sectionU06,ou=User
Accounts,dc=student,dc=cssd,dc=ab,dc=ca")
objOU.Delete user cn=047-c110-01
objOU.Delete user cn=047-c110-02
objOU.Delete user cn=047-c110-03
objOU.Delete user cn=047-c110-04
objOU.Delete user cn=047-c110-05
objOU.Delete user cn=047-c110-06
objOU.Delete user cn=047-c110-07
objOU.Delete user cn=047-c110-08
objOU.Delete user cn=047-c110-09
objOU.Delete user cn=047-c110-10
objOU.Delete user cn=047-c110-11
reply
 

Deleting users from an OU - Richard Mueller [MVP]

Wednesday, May 30, 2007 2:38 PM

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
--
reply

Thanks Richard. I tried your suggestion before posting but it didn't work. - Jeremy Schubert

Wednesday, May 30, 2007 7:46 PM

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...
reply

Deleting users from an OU - Richard Mueller [MVP]

Wednesday, May 30, 2007 8:08 PM

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.
reply

Thank you again Richard. - Jeremy Schubert

Wednesday, May 30, 2007 8:53 PM

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
reply

Previous Microsoft Scripting Visual Basicscript conversation.