Computer Performance, Windows 2003, Logon Scripts

Google

WebSearch Site

 Home
Subscribe to Newsletter
WSH - Home
WSH - Simple Script
WSH - Create User
WSH - Bulk Import
WSH - Create Group
WSH - Create Contact
WSH - FSO Create File
WSH - List Members
WSH - Error Messages
VBScript Home
Logon Script Home
CSVDE & LDIFDE
 LDAP Attributes

 

 More Sections
 Guy's eBooks
 Windows 2003
 Exchange 2003 (New)
 Performance Monitor

 

 Windows 2000 AD
 Exchange 2000
 SQL Server 2000
 SharePoint Portal

 

 Litmus Tests
 Registry Hacks
 Problem Solving
 On-line advice
 Free ebooks

 

Contact Guy
About Us
Online Jobs at CP
Guy's eBooks

 

 

WSH - Creating a New Contact

Introduction - Creating new a new Contact with WSH

This page has been superseded by two pages dealing with contacts

 

Contacts are used to create email address for people outside your company.  They do not have a security account in Active Directory (which makes the script shorter).  You could create the Contact manually with Active Directory User's and Computers.  However, there may be times when you prefer to use WSH (Windows Scripting Host) to generate new Contacts with a VBScript.

WSH Topics

Creating a new OU

Before we consider the Contact, first we need to build an OU (organizational unit) to house the Contact objects.  An advantage of having a special OU for learning about scripting is that the accounts you produce do not get mixed up with existing accounts in the Users container.  So we will call upon WSH to generate a new OU.  In my example I have called the OU MailContacts, change that name if you wish.  In WSH, the following line takes care of creating the OU:

˚

Creating the Contact = SalesMan

Set objUser = objOU.Create("contact", "cn=SalesMan")

Instructions

  1. Copy the entire Script in the green box below.
  2. Paste it into notepad.exe.
  3. File (menu), Save as SalesMan.vbs.   Note: This is where people go wrong, remember the .vbs extension.
  4. Double click SalesMan.vbs
  5. Go to Active Directory Users and Computers, Press F5, observe the MailContacts OU.

 

 

'Script to Create a new Contact account in the MailContacts OU
'Script created by Guy Thomas
'Feel free to adapt names

Set oRoot = GetObject("LDAP://rootDSE")
Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))

Set oOU=oDomain.Create("organizationalUnit", "ou=MailContacts")
oOU.Put "Description", "Guy's Contact OU"
oOU.SetInfo


Set objOU = GetObject("LDAP://OU=MailContacts, dc=cp, dc=com")
Set objUser = objOU.Create("contact", "cn=SalesMan")
objUser.SetInfo

Wscript.Echo "Success new Contact, Check Active Directory Users and Computers - Remember F5"
 

 

Note 1: If you run the script a second time, you will need to deal with the fact that that the OU already exists.  Either 'rem out the line (Best) or delete the OU in Active Directory.

If you get an error message - check this page

See Also

 *


Google

Webcomputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.