tbaseflug
asked on
sending email upon logon
Am working with W2k - what I need is some form of script or program that will email me when a user logs into the server?
ASKER
craylord -
I am an idiot when it comes to OS scripts - how and what do I need to do to get this to run - is it a login script?
I am an idiot when it comes to OS scripts - how and what do I need to do to get this to run - is it a login script?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
craylord -
THanks - let me give it a try - our DC is down right now but will test it right after it gets back online
THanks - let me give it a try - our DC is down right now but will test it right after it gets back online
\\server01\log
\\server01\log\inventory
\\server01\log\inventory\c
\\server01\log\logins
\\server01\log\logins\comp
\\server01\log\logins\csv
\\server01\log\software
and a text file here
\\server01\log\check3.txt
;-------------------------
; The first portion of the script does five things
; 1) Writes basic computer information to a text file = NetBIOS
; name.txt (overwrites)
; 2) Writes logon time to a text file = username.txt (appends)
; 3) Writes logon time to a text file = NetBIOS name.txt (appends)
; 4) Writes all logon info to a .csv file (appends)
; 5) Writes computer info to a .csv one time only for inventory
; purposes
Use Z: /Delete /persistent
Use Z: "\\server01\log"
; 1) Basic computer info for reference
ReDirectOutput ("Z:\Inventory\@WKSTA.txt"
?"NetBIOS name = "@WKSTA
?"Last login by "@USERID
?"OS = "@PRODUCTTYPE" with "@CSD
?"Memory = "MemorySize(0)" MB"
?"Processor type is "@CPU
?"Processor speed is "@MHZ
?"IP address = "@IPADDRESS0
?"MAC address = "@ADDRESS
?"This information was gathered on "@DATE" at "@TIME
; 2) Tracks all logons by user
ReDirectOutput ("Z:\Logins\@USERID.txt",0
?@USERID" logged into the "@domain" domain on "@WKSTA" at "@TIME" on "@DATE" "
; 3) Tracks all logons by computer
ReDirectOutput ("Z:\Logins\Computer\@WKST
?@USERID" logged into the "@domain" domain on "@WKSTA" at "@TIME" on "@DATE" "
; 4) Records all logon info to a .csv file
ReDirectOutput ("Z:\Logins\CSV\logins.txt
?@USERID","@WKSTA","@DATE"
; 5) Records computer info one time to a .csv file and copies a check file
; to prevent future writes of same computer
If Exist ("c:\check3.txt")
Goto "software"
EndIf
ReDirectOutput ("Z:\Inventory\CSV\invento
?@FULLNAME","@WKSTA","$sub
Copy "Z:\check3.txt" "c:\check3.txt"
; The second part of this script performs an inventory of installed software on a PC
; by examining the portion of the registry where uninstall information is kept.
; The information is then recorded to a text file = computer name that is overwritten
; with each successive logon.
:software
ReDirectOutput ("Z:\Software\@HOSTNAME.tx
?"Software installed on @HOSTNAME as of @DATE"
?
; Scroll through each subkey
$Index = 0
:Loop1
$KeyName = EnumKey("HKEY_LOCAL_MACHIN
If @ERROR = 0
Goto DisplayCheck
Else
Goto End
EndIf
:DisplayCheck
; Check for DisplayName string, record information if it exists
$Displayname = ReadValue("HKEY_LOCAL_MACH
; DisplayName exists
If @ERROR = 0
?$Displayname
$Index = $Index + 1
Goto Loop1
; DisplayName does not exist
Else
$Index = $Index + 1
Goto Loop1
:End
; Finished checking all subkeys, exit program
Use Z: /Delete /persistent
exit
FUNCTION WMIQuery($what,$where,)
dim $strQuery, $objEnumerator, $value
$strQuery = "Select $what From $where"
$SystemSet = GetObject("winmgmts:{imper
$objEnumerator = $SystemSet.ExecQuery($strQ
For Each $objInstance in $objEnumerator
If @Error = 0 and $objInstance <> ""
$=execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$W
EndIf Next $WMIQuery=left($WMIQuery,l
exit @error
ENDFUNCTION
$computer = @wksta
;? WMIQuery2("Services on","Win32_Service")
;? WMIQuery2("Processes on","Win32_Process")
FUNCTION WMIQuery2($what,$where,)
$wmi = GetObject("winmgmts:{imper
$list = ""
$objs = $wmi.instancesof($where)
for each $obj in $objs
$list = $list + $obj.description + chr(13) + chr(10)
next
$list=Left($list, Len($list))
; ?$what +" "+ $computer + chr(13) + chr(10) + $list
ENDFUNCTION
Exit