Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: Scripting error

Reply
Thread Tools Display Modes

Re: Scripting error

 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      12-11-2009

"Tom Lavedas" <> wrote in message
news:d3d95b90-bae7-4c5e-ac1b-...
On Dec 11, 2:25 pm, dragon <dragon.431...@DoNotSpam.com> wrote:
> Who can help me solve this problem please?
>
> set Args = Wscript.ArgumentsouName = Args(0)
>
> Object does not support this property or method. This bit of code came
> from configuring roaming profile in Window 2003 server.................
>
> Someone is willing to explain to me what this script would be nice
> too.
>
> If I run this script with argument says cscript roamingprofile.vbs
> \\server\shareserver\firstname, will it split up to userName = firstname
> and RUProot= \\server\shareserver ? I couldn't figure out.
>
> Thanks
>
> set Args = Wscript.ArgumentsouName = Args(0)
> usrName = Args(1)
> RUProot = Args(2)
>
> RUPpath = RUProot & " \" & usrName
>
> 'Get the domain
> Set dse = GetObject(" LDAP://RootDSE" )
> Set domain = GetObject( " LDAP://" & dse.Get(" defaultNamingContext"
> ))
>
> set ou = domain.GetObject(" organizationalUnit" , " OU=" & ouName )
>
> wscript.echo " Creating user in " & ou.Name
>
> set usr = ou.Create(" user" , " cn=" & usrName )
> usr.Put " samAccountName" , usrName
> usr.Put " userPrincipalName" , usrName
> usr.Put " Profilepath" , RUPpath
>
> usr.SetInfo
>
> wscript.echo
>
> --
> dragon
> ------------------------------------------------------------------------
> dragon's Profile:http://forums.techarena.in/members/76434.htm
> View this thread:http://forums.techarena.in/server-scripting/1281310.htm
>
> http://forums.techarena.in


It would appear to me that there is a missing newline in there. I
would expect it is supposed to be ...

set Args = Wscript.Arguments
ouName = Args(0)

What do you mean "explain to me what this script [does?]"?

It will NOT parse a supplied command line argument in the form "\
\server\shareserver\firstname" into its components. It is constructed
under the assumption that there are THREE arguments in the form of ...

cscript roamingprofile.vbs someOUName username \\server\shareserver

User admin is not my domain, but the script as written does not parse
the inputs into its component parts. Parsing can be done, but since I
am unfamiliar with exactly what the component parts are supposed to
be, I think I'll leave that to someone more versed in such things.
_____________________
Tom Lavedas
=========

The script creates a user object in a specified OU and assigns the
profilePath attribute. The first parameter passed to the program should the
the name (relative distinguished name) of an OU, which must be at the root
of the domain (it cannot be nested in another OU). The second parameter will
be both the Common Name (value of the cn attribute) and the "pre-Windows
2000 logon" name (value of the sAMAccountName attribute) of the new user, so
the value must be unique in the domain. It will also be assigned as the
userPrincipalName (which in this case must be unique in the domain). The
third parameter is the share name where user profiles will be saved. The
script should be run with a command line similar to what Tom suggested.

The problem with the script is that every quoted string has a leading space,
which leads to errors. When I tested the script I replaced every instance of
a quote followed by a space with just a quote character. I then removed the
leading quote in the following GetObject statement:

Set domain = GetObject( " LDAP://" & dse.Get(" defaultNamingContext"))

This should read:

Set domain = GetObject("LDAP://" & dse.Get("defaultNamingContext"))

This is an interesting way to bind to an OU object, and it works, but only
if the OU is at the root of the domain. It will fail if the OU is the child
of another OU. The version of the script I used to test follows:
===========
set Args = Wscript.Arguments
ouName = Args(0)
usrName = Args(1)
RUProot = Args(2)

RUPpath = RUProot & "\" & usrName

'Get the domain
Set dse = GetObject("LDAP://RootDSE")
Set domain = GetObject("LDAP://" & dse.Get("defaultNamingContext"))

' Requires ou=ouName be at the root of the domain.
set ou = domain.GetObject("organizationalUnit", "OU=" & ouName )

wscript.echo "Creating user in " & ou.Name

set usr = ou.Create("user", "cn=" & usrName )
usr.Put "samAccountName", usrName
usr.Put "userPrincipalName", usrName
usr.Put "Profilepath", RUPpath

usr.SetInfo

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Server2003 2008 error !! Paul Bergson [MVP-DS] Active Directory 0 11-27-2009 12:19 PM
Re: Server2003 2008 error !! Meinolf Weber [MVP-DS] Active Directory 0 11-26-2009 01:37 PM
Question regarding 'Event12, Kernel-WHEA' Error Log sangwooksohn Windows Vista Hardware 6 02-19-2008 02:40 PM
Unresolved items: incredible! Massimo ActiveSync 9 04-18-2006 03:11 PM
ActiveSync 4.1, Calendar and "Processing" Dale Reeck ActiveSync 10 12-20-2005 12:44 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59