'====================================================================
'= Show NetWare Server Last Logon 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/).
'=
'====================================================================
'====================================================================
'==
'== nwLastLogin.vbs - script to list all the users on a Server
'==
'====================================================================
set fso = createobject ( "Scripting.FileSystemObject")

'====================================================================
'== Get the NetWare Server and the output file
'====================================================================
if wscript.arguments.count = 0 then
   wscript.echo ( "Usage: nwLastLogin.vbs <Server> <Path to Ouput file>")
   svrPath = inputbox ( "Enter the server that you want the last login dates for the users:")
   outPath = inputbox ( "Enter the path to the output file:")
elseif wscript.arguments.item ( 0) = "/?" Or wscript.arguments.item ( 0) = "-?" then
   wscript.echo ( "Usage: nwLastLogin.vbs <Server> <Path to Ouput file>")
   wscript.quit ( )
else
   svrPath = wscript.arguments.item ( 0)
   outPath = wscript.arguments.item ( 1)
end if

'====================================================================
'== validate that there was something passed to the script
'====================================================================
if svrPath = "" or outPath = "" then
   wscript.echo ( "There were not enough arguments passed to the script")
   wscript.echo ( "Usage: nwLastLogin.vbs <Server> <Path to Ouput file>")
   wscript.quit ( )
end if

'====================================================================
'== Open the base out file
'====================================================================
set outFile = fso.createtextfile ( outPath)

on error resume next

'====================================================================
'== Now try to bind to the 3.x server
'====================================================================
svrPath = "NWCOMPAT://" & svrPath
set srvObj = getobject ( svrPath)

'====================================================================
'== Apply the user filter and then list the users
'====================================================================
srvObj.filter = "User"

for each usr in srvObj
   if usr.class = "User" then
      outFile.writeline ( usr.name & "," & usr.lastlogin )
   end if
next

'====================================================================
'== Dump the reference to the server
'====================================================================
set srvObj = nothing

'====================================================================
'== Clean up the out file reference and the file system object
'====================================================================
outFile.close
set outFile = nothing

set fso = nothing

wscript.quit ( )


Copyright © 2005 - 2013 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.