'====================================================================
'= Specific User Check VBScript sample - Copyright © 2007, Dave Moats
'=
'= This sample is provided 'as-is', without any express or implied warranty.
'= In no event will the authors be held liable for any damages arising from
'= the use of this sample code.
'=
'= Permission is granted to anyone to use this sample code for any purpose,
'= including commercial applications, subject to the following restrictions:
'=
'= The origin of this code must not be misrepresented;
'= you must not claim that you wrote the original code.
'= If you use this code, an acknowledgment in the
'= documentation is requested - shown below:
'=
'= Portions Copyright © 2007, Dave Moats (http://www.davemoats.com/).
'=
'====================================================================
'====================================================================
'==
'== checkUsers.vbs - script to check specific users
'==
'====================================================================
set fso = createobject ( "Scripting.FileSystemObject")
'====================================================================
'== get the info required to run the script
'====================================================================
if wscript.arguments.count = 0 then
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
domName = inputbox ( "Enter the Domain that you want to check:")
inPath = inputbox ( "Enter the path to the input file:")
outPath = inputbox ( "Enter the path to the output file:")
elseif wscript.arguments.item ( 0) = "/?" Or wscript.arguments.item ( 0) = "-?" then
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
wscript.quit ( )
else
domName = wscript.arguments.item ( 0)
inPath = wscript.arguments.item ( 1)
outPath = wscript.arguments.item ( 2)
end if
'====================================================================
'== Make sure we have some info
'====================================================================
if domName = "" or inPath = "" or outPath = "" then
wscript.echo ( "There were not enough arguments passed to the script")
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
wscript.quit ( )
end if
'====================================================================
'== Open the base out file
'====================================================================
set inputFile = fso.opentextfile ( inPath )
set outputFile = fso.createtextfile ( outPath )
on error resume next
do while not ( inputFile.atendofstream)
usrName = inputFile.readline
usrPath = "WinNT://" & domName & "/" & usrName
set usrObj = getobject ( usrPath)
outMsg = usrName
'==================================================================
'== try get the user's full name and add to our string
'==================================================================
fname = usrObj.FullName
if fname <> "" then
outMsg = outMsg & "," & fname
else
outMsg = outMsg & ","
end if
'==================================================================
'== try get the user's description and add to our string
'==================================================================
cmt = usrObj.Description
if cmt <> "" then
outMsg = outMsg & "," & cmt
else
outMsg = outMsg & ","
end if
'==================================================================
'== see if the account is disabled and add to our string
'==================================================================
if usrObj.AccountDisabled = true then
outMsg = outMsg & ",Disabled"
else
outMsg = outMsg & ",Enabled"
end if
outputFile.writeline ( outMsg )
set usrObj = nothing
loop
'====================================================================
'== Clean up the main input and log files
'====================================================================
outputFile.close
set outputFile = nothing
inputFile.close
set inputFile = nothing
set fso = nothing
wscript.quit ( )
'= Specific User Check VBScript sample - Copyright © 2007, Dave Moats
'=
'= This sample is provided 'as-is', without any express or implied warranty.
'= In no event will the authors be held liable for any damages arising from
'= the use of this sample code.
'=
'= Permission is granted to anyone to use this sample code for any purpose,
'= including commercial applications, subject to the following restrictions:
'=
'= The origin of this code must not be misrepresented;
'= you must not claim that you wrote the original code.
'= If you use this code, an acknowledgment in the
'= documentation is requested - shown below:
'=
'= Portions Copyright © 2007, Dave Moats (http://www.davemoats.com/).
'=
'====================================================================
'====================================================================
'==
'== checkUsers.vbs - script to check specific users
'==
'====================================================================
set fso = createobject ( "Scripting.FileSystemObject")
'====================================================================
'== get the info required to run the script
'====================================================================
if wscript.arguments.count = 0 then
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
domName = inputbox ( "Enter the Domain that you want to check:")
inPath = inputbox ( "Enter the path to the input file:")
outPath = inputbox ( "Enter the path to the output file:")
elseif wscript.arguments.item ( 0) = "/?" Or wscript.arguments.item ( 0) = "-?" then
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
wscript.quit ( )
else
domName = wscript.arguments.item ( 0)
inPath = wscript.arguments.item ( 1)
outPath = wscript.arguments.item ( 2)
end if
'====================================================================
'== Make sure we have some info
'====================================================================
if domName = "" or inPath = "" or outPath = "" then
wscript.echo ( "There were not enough arguments passed to the script")
wscript.echo ( "Usage: checkUsers.vbs <Domain Name> <Path to Input file> <Path to Ouput file>")
wscript.quit ( )
end if
'====================================================================
'== Open the base out file
'====================================================================
set inputFile = fso.opentextfile ( inPath )
set outputFile = fso.createtextfile ( outPath )
on error resume next
do while not ( inputFile.atendofstream)
usrName = inputFile.readline
usrPath = "WinNT://" & domName & "/" & usrName
set usrObj = getobject ( usrPath)
outMsg = usrName
'==================================================================
'== try get the user's full name and add to our string
'==================================================================
fname = usrObj.FullName
if fname <> "" then
outMsg = outMsg & "," & fname
else
outMsg = outMsg & ","
end if
'==================================================================
'== try get the user's description and add to our string
'==================================================================
cmt = usrObj.Description
if cmt <> "" then
outMsg = outMsg & "," & cmt
else
outMsg = outMsg & ","
end if
'==================================================================
'== see if the account is disabled and add to our string
'==================================================================
if usrObj.AccountDisabled = true then
outMsg = outMsg & ",Disabled"
else
outMsg = outMsg & ",Enabled"
end if
outputFile.writeline ( outMsg )
set usrObj = nothing
loop
'====================================================================
'== Clean up the main input and log files
'====================================================================
outputFile.close
set outputFile = nothing
inputFile.close
set inputFile = nothing
set fso = nothing
wscript.quit ( )
Copyright © 2010 Dave Moats. All rights reserved. Links: Copyright © by their respective owners.
NO WARRANTIES EXTENDED. Void where prohibited by law. Please report any issues or broken links.
You may link to this site freely from your own site. You may quote from this site, but please include a link to the original source on the originating site.