Posted by: Preetam | October 17, 2007

Step01-OUCreation

$OUName=read-host “Please enter the OU name you wish to create”

$objUser = [ADSI]”LDAP://localhost:389/dc=contoso,dc=com”

$ou=$objUser.create(“organizationalunit”, “ou=$OUName”)

$ou.setinfo()

# ============================

$date=get-date

$futdate=$date.addseconds(5)

$towait=$futdate – $date

$waittime=$towait.seconds

while($waittime -gt 0) {

$waittime=$waittime-1

write-host “Warning: Operation is in progress …” -foreground yellow

start-sleep -s 1

if($waittime -le 0) {

$OUcreated=[ADSI]”LDAP://localhost:389/ou=$OUname,dc=contoso,dc=com”

If($OUcreated.true){

Write-host $OUname OU is created successfully -ForegroundColor “Green”

}

}

}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: