Home All Groups Group Topic Archive Search About

Scripting Newbie needs help



Author
16 Mar 2007 11:14 PM
Pat Hall
I get this error when I run my script form the command line csrcipt
retrieve_TS_Profile_ISD.vbs).     

U:\MyFiles\MISC\AD_Scripts\VB_Examples\retrieve_TS_Profile_ISD.vbs(10, 5)
Micros
oft VBScript compilation error: Expected statement

Code is:

Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2

strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
strUser = "domain\account"
strPassword = "xxxxxxxxxxx"

Set DSO = GetObject("LDAP:")
Set usr = DSO.OpenDSObject_
    (strPath, strUser, strPassword, _
        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)

For Each  usr in strPath
   Wscript.echo usr.TerminalServicesProfilePath
   Wscript.echo usr.TerminalServicesHomeDirectory
   Wscript.echo usr.TerminalServicesHomeDrive
   Wscript.echo usr.AllowLogon
   Wscript.Echo
Next

Author
17 Mar 2007 12:51 AM
Richard Mueller [MVP]
Pat Hall wrote:

Show quote
>I get this error when I run my script form the command line csrcipt
> retrieve_TS_Profile_ISD.vbs).
>
> U:\MyFiles\MISC\AD_Scripts\VB_Examples\retrieve_TS_Profile_ISD.vbs(10, 5)
> Micros
> oft VBScript compilation error: Expected statement
>
> Code is:
>
> Const ADS_SECURE_AUTHENTICATION = 1
> Const ADS_USE_ENCRYPTION = 2
>
> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
> strUser = "domain\account"
> strPassword = "xxxxxxxxxxx"
>
> Set DSO = GetObject("LDAP:")
> Set usr = DSO.OpenDSObject_
>    (strPath, strUser, strPassword, _
>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)


You need a space between OpenDSObject and the underscore line continuation
character. Otherwise, OpenDSObject_ is one token to the interpreter.

Show quote
>
> For Each  usr in strPath
>   Wscript.echo usr.TerminalServicesProfilePath
>   Wscript.echo usr.TerminalServicesHomeDirectory
>   Wscript.echo usr.TerminalServicesHomeDrive
>   Wscript.echo usr.AllowLogon
>   Wscript.Echo
> Next

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
Author
17 Mar 2007 1:10 AM
Richard Mueller [MVP]
Show quote
"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:O6tqR6CaHHA.4692@TK2MSFTNGP04.phx.gbl...
> Pat Hall wrote:
>
>>I get this error when I run my script form the command line csrcipt
>> retrieve_TS_Profile_ISD.vbs).
>>
>> U:\MyFiles\MISC\AD_Scripts\VB_Examples\retrieve_TS_Profile_ISD.vbs(10, 5)
>> Micros
>> oft VBScript compilation error: Expected statement
>>
>> Code is:
>>
>> Const ADS_SECURE_AUTHENTICATION = 1
>> Const ADS_USE_ENCRYPTION = 2
>>
>> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
>> strUser = "domain\account"
>> strPassword = "xxxxxxxxxxx"
>>
>> Set DSO = GetObject("LDAP:")
>> Set usr = DSO.OpenDSObject_
>>    (strPath, strUser, strPassword, _
>>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
>
>
> You need a space between OpenDSObject and the underscore line continuation
> character. Otherwise, OpenDSObject_ is one token to the interpreter.
>
>>
>> For Each  usr in strPath
>>   Wscript.echo usr.TerminalServicesProfilePath
>>   Wscript.echo usr.TerminalServicesHomeDirectory
>>   Wscript.echo usr.TerminalServicesHomeDrive
>>   Wscript.echo usr.AllowLogon
>>   Wscript.Echo
>> Next
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>

Also, you are enumerating a string instead of the OU object at the end. And,
you are assuming that all of the child objects are users. I would suggest:

Set DSO = GetObject("LDAP:")
Set objOU = DSO.OpenDSObject _
   (strPath, strUser, strPassword, _
       ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)

objOU.Filter = Array("user")

For Each  usr in objOU
  Wscript.echo usr.TerminalServicesProfilePath
  Wscript.echo usr.TerminalServicesHomeDirectory
  Wscript.echo usr.TerminalServicesHomeDrive
  Wscript.echo usr.AllowLogon
  Wscript.Echo
Next

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
Author
17 Mar 2007 4:04 PM
Pat Hall
Thanks.  Made the changes you suggested.  Now I'm getting the error "The
server is not operational".  I googled the error and checked the spelling of
everthing.  Any chance I need to add some more code so the script knows
exactly where to look?  The server is operational.

Script is now:

Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2

'On Error Resume Next

strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
strUser = "domain\account"
strPassword = "xxxxxxxxx"

Set DSO = GetObject("LDAP:")
Set objOU = DSO.OpenDSObject _
    (strPath, strUser, strPassword, _
        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)

objOU.Filter = Array("user")

For Each  usr in objOU
   Wscript.echo usr.TerminalServicesProfilePath
   Wscript.echo usr.TerminalServicesHomeDirectory
   Wscript.echo usr.TerminalServicesHomeDrive
   Wscript.echo usr.AllowLogon
   Wscript.Echo
Next


Show quote
"Richard Mueller [MVP]" wrote:

>
> "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
> message news:O6tqR6CaHHA.4692@TK2MSFTNGP04.phx.gbl...
> > Pat Hall wrote:
> >
> >>I get this error when I run my script form the command line csrcipt
> >> retrieve_TS_Profile_ISD.vbs).
> >>
> >> U:\MyFiles\MISC\AD_Scripts\VB_Examples\retrieve_TS_Profile_ISD.vbs(10, 5)
> >> Micros
> >> oft VBScript compilation error: Expected statement
> >>
> >> Code is:
> >>
> >> Const ADS_SECURE_AUTHENTICATION = 1
> >> Const ADS_USE_ENCRYPTION = 2
> >>
> >> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
> >> strUser = "domain\account"
> >> strPassword = "xxxxxxxxxxx"
> >>
> >> Set DSO = GetObject("LDAP:")
> >> Set usr = DSO.OpenDSObject_
> >>    (strPath, strUser, strPassword, _
> >>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
> >
> >
> > You need a space between OpenDSObject and the underscore line continuation
> > character. Otherwise, OpenDSObject_ is one token to the interpreter.
> >
> >>
> >> For Each  usr in strPath
> >>   Wscript.echo usr.TerminalServicesProfilePath
> >>   Wscript.echo usr.TerminalServicesHomeDirectory
> >>   Wscript.echo usr.TerminalServicesHomeDrive
> >>   Wscript.echo usr.AllowLogon
> >>   Wscript.Echo
> >> Next
> >
> > --
> > Richard Mueller
> > Microsoft MVP Scripting and ADSI
> > Hilltop Lab - http://www.rlmueller.net
> > --
> >
> >
>
> Also, you are enumerating a string instead of the OU object at the end. And,
> you are assuming that all of the child objects are users. I would suggest:
>
> Set DSO = GetObject("LDAP:")
> Set objOU = DSO.OpenDSObject _
>    (strPath, strUser, strPassword, _
>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
>
> objOU.Filter = Array("user")
>
> For Each  usr in objOU
>   Wscript.echo usr.TerminalServicesProfilePath
>   Wscript.echo usr.TerminalServicesHomeDirectory
>   Wscript.echo usr.TerminalServicesHomeDrive
>   Wscript.echo usr.AllowLogon
>   Wscript.Echo
> Next
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
Author
17 Mar 2007 5:40 PM
Richard Mueller [MVP]
Pat wrote:

Show quote
> Thanks.  Made the changes you suggested.  Now I'm getting the error "The
> server is not operational".  I googled the error and checked the spelling
> of
> everthing.  Any chance I need to add some more code so the script knows
> exactly where to look?  The server is operational.
>
> Script is now:
>
> Const ADS_SECURE_AUTHENTICATION = 1
> Const ADS_USE_ENCRYPTION = 2
>
> 'On Error Resume Next
>
> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
> strUser = "domain\account"
> strPassword = "xxxxxxxxx"
>
> Set DSO = GetObject("LDAP:")
> Set objOU = DSO.OpenDSObject _
>    (strPath, strUser, strPassword, _
>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
>
> objOU.Filter = Array("user")
>
> For Each  usr in objOU
>   Wscript.echo usr.TerminalServicesProfilePath
>   Wscript.echo usr.TerminalServicesHomeDirectory
>   Wscript.echo usr.TerminalServicesHomeDrive
>   Wscript.echo usr.AllowLogon
>   Wscript.Echo
> Next
>

The problem is ADS_USE_ENCRYPTION. Remove this and it will probably work.
I'm investigating when you can use it.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
Author
17 Mar 2007 5:53 PM
Richard Mueller [MVP]
Show quote
"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:%23DYp%23tLaHHA.4940@TK2MSFTNGP05.phx.gbl...
> Pat wrote:
>
>> Thanks.  Made the changes you suggested.  Now I'm getting the error "The
>> server is not operational".  I googled the error and checked the spelling
>> of
>> everthing.  Any chance I need to add some more code so the script knows
>> exactly where to look?  The server is operational.
>>
>> Script is now:
>>
>> Const ADS_SECURE_AUTHENTICATION = 1
>> Const ADS_USE_ENCRYPTION = 2
>>
>> 'On Error Resume Next
>>
>> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
>> strUser = "domain\account"
>> strPassword = "xxxxxxxxx"
>>
>> Set DSO = GetObject("LDAP:")
>> Set objOU = DSO.OpenDSObject _
>>    (strPath, strUser, strPassword, _
>>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
>>
>> objOU.Filter = Array("user")
>>
>> For Each  usr in objOU
>>   Wscript.echo usr.TerminalServicesProfilePath
>>   Wscript.echo usr.TerminalServicesHomeDirectory
>>   Wscript.echo usr.TerminalServicesHomeDrive
>>   Wscript.echo usr.AllowLogon
>>   Wscript.Echo
>> Next
>>
>
> The problem is ADS_USE_ENCRYPTION. Remove this and it will probably work.
> I'm investigating when you can use it.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>

Ah, ADS_USE_ENCRYPTION is the same as ADS_USE_SSL. They both have the value
2. AD requires that the Certificate Server be installed to support SSL.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
Author
18 Mar 2007 4:24 AM
Pat Hall
Thanks.  That fixed the problem.   Thanks for all your help.

Show quote
"Richard Mueller [MVP]" wrote:

>
> "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
> message news:%23DYp%23tLaHHA.4940@TK2MSFTNGP05.phx.gbl...
> > Pat wrote:
> >
> >> Thanks.  Made the changes you suggested.  Now I'm getting the error "The
> >> server is not operational".  I googled the error and checked the spelling
> >> of
> >> everthing.  Any chance I need to add some more code so the script knows
> >> exactly where to look?  The server is operational.
> >>
> >> Script is now:
> >>
> >> Const ADS_SECURE_AUTHENTICATION = 1
> >> Const ADS_USE_ENCRYPTION = 2
> >>
> >> 'On Error Resume Next
> >>
> >> strPath = "LDAP://OU=ISD,OU=GSO,DC=gso,DC=gilbarco,DC=com"
> >> strUser = "domain\account"
> >> strPassword = "xxxxxxxxx"
> >>
> >> Set DSO = GetObject("LDAP:")
> >> Set objOU = DSO.OpenDSObject _
> >>    (strPath, strUser, strPassword, _
> >>        ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)
> >>
> >> objOU.Filter = Array("user")
> >>
> >> For Each  usr in objOU
> >>   Wscript.echo usr.TerminalServicesProfilePath
> >>   Wscript.echo usr.TerminalServicesHomeDirectory
> >>   Wscript.echo usr.TerminalServicesHomeDrive
> >>   Wscript.echo usr.AllowLogon
> >>   Wscript.Echo
> >> Next
> >>
> >
> > The problem is ADS_USE_ENCRYPTION. Remove this and it will probably work.
> > I'm investigating when you can use it.
> >
> > --
> > Richard Mueller
> > Microsoft MVP Scripting and ADSI
> > Hilltop Lab - http://www.rlmueller.net
> > --
> >
> >
>
> Ah, ADS_USE_ENCRYPTION is the same as ADS_USE_SSL. They both have the value
> 2. AD requires that the Certificate Server be installed to support SSL.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

AddThis Social Bookmark Button