Discussion:
Scripting error
(too old to reply)
dragon
2009-12-11 19:25:10 UTC
Permalink
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 cam
from configuring roaming profile in Window 2003 server.................

Someone is willing to explain to me what this script would be nic
too.

If I run this script with argument says cscript roamingprofile.vb
\\server\shareserver\firstname, will it split up to userName = firstnam
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.ech

--
drago
-----------------------------------------------------------------------
dragon's Profile: http://forums.techarena.in/members/76434.ht
View this thread: http://forums.techarena.in/server-scripting/1281310.ht

http://forums.techarena.i
Tom Lavedas
2009-12-11 20:39:25 UTC
Permalink
Post by dragon
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
dragon
2009-12-11 21:58:16 UTC
Permalink
Thanks Tom for solving the two problems. I got a better idea now.
--
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
Richard Mueller [MVP]
2009-12-11 22:35:39 UTC
Permalink
Post by dragon
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
--
dragon
2009-12-12 07:31:29 UTC
Permalink
Thanks Richard.
--
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
Loading...