I need a Powershell script that will be used as LogOn / LogOff script on Active Directory.
Script needs to log the following information on a CSV file on an UNC share :
- LogOn or LogOff (Depending if user logs on or off).
- Username
- Date
- Time
- Computer Name
- IP address
- Client Name ( This information will only be saved if the user logs on on a TERMINAL Server ).
Example : User logs on from PCX onto Terminal Server TS1 , PCX name will be saved as ClientName and TS1 will be saved as ComputerName.
- Logon Server
Same script will save on a separate file the following information :
Username, Computer Name, IP Address, Computer Serial Number (Yes, this information is available via powershell).
Filename must have the same name as the date. For example if the date is 20 May 2014 , the filename must be [login to view URL]
All the logon / log off for that date must be saved in the same file so I can see daily logons.
The other file must be saved as %USERNAME%.CSV so Each User will have his file where I can see a history of who logged on which computer and what IP addresses they used.
If something not clear please let me know.
Example of CSV file attached.
I am currently making the script and should be done by the end of the day. Thus far I am using just an easy formatting for logging and then i will output it to csv.