Good afternoon,

Here is what I would like to achieve but do not know how!

I would like to create a script that

1- run dos command "net group GROUPNAME /domain" and write it to a textfile
2- Using the textfile of users, run the dos command "net user USERNAME
/domain" (using 1 by 1 the user from the textfile in 1) and write it to
another textfile
3- Go through the textfile created in 2 and validate certain parameter such
as "logon script".

Can someone run me through this or point me to a web site that can provide
me with the basics on how I can do this type of script.

One of my main problem is how I can use the text file created in 1 in 2
since it is output in a tabular format (3 columns) and vbs will read it 1
line at a time. How can I transform the dos output into a valid format to
use in 2?

Thank you for any help!

Daniel

Re: Domain information through vbs by Richard

Richard
Wed Jul 20 16:23:22 CDT 2005

Daniel wrote:

> Here is what I would like to achieve but do not know how!
>
> I would like to create a script that
>
> 1- run dos command "net group GROUPNAME /domain" and write it to a
textfile
> 2- Using the textfile of users, run the dos command "net user USERNAME
> /domain" (using 1 by 1 the user from the textfile in 1) and write it to
> another textfile
> 3- Go through the textfile created in 2 and validate certain parameter
such
> as "logon script".
>
> Can someone run me through this or point me to a web site that can provide
> me with the basics on how I can do this type of script.
>
> One of my main problem is how I can use the text file created in 1 in 2
> since it is output in a tabular format (3 columns) and vbs will read it 1
> line at a time. How can I transform the dos output into a valid format to
> use in 2?

Hi,

A problem I see is the header information output by these commands. The
script would have to parse through this to find the member names, then parse
for logon script. Also, you would have a separate output file for each
member. This can be done using the FileSystemObject. You would use the Run
method of the wshShell object to run the DOS commands and redirect the
output to a file, then use the FileSystemObject to read the file. However,
it would be much easier to read the information directly from Active
Directory using ADSI. For example:

' Specify the group Distinguished Name.
strGroup = "cn=MyGroup,ou=Sales,dc=MyDomain,dc=com"

' Bind to the group object in Active Directory.
Set objGroup = GetObject("LDAP://" & strGroup)

' Enumerate direct members of the group.
For Each objMember In objGroup.Members
' Only consider members that are users (skip groups).
If (objMember.Class = "user") Then
' Output user NT name and logon script.
Wscript.Echo objMember.sAMAccountName & ", " & objMember.scriptPath
End If
Next

This VBScript program could be run at a command prompt, with the output
redirected to a text file. If you really need to use the DOS commands and
intermediate files, reply. Otherwise, for documentation on other attributes
available for user objects (like scriptPath and sAMAccountName), see this
link:

http://www.rlmueller.net/UserAttributes.htm

The first spreadsheet documents the attributes corresponding to the fields
in the Properties dialog for users in ADUC.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--



Re: Domain information through vbs by Daniel

Daniel
Thu Jul 21 06:48:02 CDT 2005

Richard,

Sadly we do not have/use Active Directory so I am stuck using dos (for now
at least). Could you help me some more please.

Thanks,

Daniel

"Richard Mueller [MVP]" wrote:

> Daniel wrote:
>
> > Here is what I would like to achieve but do not know how!
> >
> > I would like to create a script that
> >
> > 1- run dos command "net group GROUPNAME /domain" and write it to a
> textfile
> > 2- Using the textfile of users, run the dos command "net user USERNAME
> > /domain" (using 1 by 1 the user from the textfile in 1) and write it to
> > another textfile
> > 3- Go through the textfile created in 2 and validate certain parameter
> such
> > as "logon script".
> >
> > Can someone run me through this or point me to a web site that can provide
> > me with the basics on how I can do this type of script.
> >
> > One of my main problem is how I can use the text file created in 1 in 2
> > since it is output in a tabular format (3 columns) and vbs will read it 1
> > line at a time. How can I transform the dos output into a valid format to
> > use in 2?
>
> Hi,
>
> A problem I see is the header information output by these commands. The
> script would have to parse through this to find the member names, then parse
> for logon script. Also, you would have a separate output file for each
> member. This can be done using the FileSystemObject. You would use the Run
> method of the wshShell object to run the DOS commands and redirect the
> output to a file, then use the FileSystemObject to read the file. However,
> it would be much easier to read the information directly from Active
> Directory using ADSI. For example:
>
> ' Specify the group Distinguished Name.
> strGroup = "cn=MyGroup,ou=Sales,dc=MyDomain,dc=com"
>
> ' Bind to the group object in Active Directory.
> Set objGroup = GetObject("LDAP://" & strGroup)
>
> ' Enumerate direct members of the group.
> For Each objMember In objGroup.Members
> ' Only consider members that are users (skip groups).
> If (objMember.Class = "user") Then
> ' Output user NT name and logon script.
> Wscript.Echo objMember.sAMAccountName & ", " & objMember.scriptPath
> End If
> Next
>
> This VBScript program could be run at a command prompt, with the output
> redirected to a text file. If you really need to use the DOS commands and
> intermediate files, reply. Otherwise, for documentation on other attributes
> available for user objects (like scriptPath and sAMAccountName), see this
> link:
>
> http://www.rlmueller.net/UserAttributes.htm
>
> The first spreadsheet documents the attributes corresponding to the fields
> in the Properties dialog for users in ADUC.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
>
>
>

Re: Domain information through vbs by Jerold

Jerold
Thu Jul 21 08:27:30 CDT 2005

On Wed, 20 Jul 2005 13:34:03 -0700, Daniel <Daniel@discussions.microsoft.com> wrote:

>Good afternoon,
>
> Here is what I would like to achieve but do not know how!
>
> I would like to create a script that
>
>1- run dos command "net group GROUPNAME /domain" and write it to a textfile
>2- Using the textfile of users, run the dos command "net user USERNAME
>/domain" (using 1 by 1 the user from the textfile in 1) and write it to
>another textfile
>3- Go through the textfile created in 2 and validate certain parameter such
>as "logon script".
>
>Can someone run me through this or point me to a web site that can provide
>me with the basics on how I can do this type of script.
>
>One of my main problem is how I can use the text file created in 1 in 2
>since it is output in a tabular format (3 columns) and vbs will read it 1
>line at a time. How can I transform the dos output into a valid format to
>use in 2?
>
>Thank you for any help!
>
>Daniel

If you don't mind using a bat file, see
tip 9135 » How can a script process the members of a domain group?
in the 'Tips & Tricks' at http://www.jsifaq.com
See tip 5527 » How can I retrieve basic user data?