Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user activity

Status
Not open for further replies.

surecomms

IS-IT--Management
Jul 2, 2009
3
GB
I am running sbs2008 and need to find out the what time people are logging in on their workstations also we use the RWW it would be good to see what time people were logging on there too. can this e done in powershell?
 
You will either need to enable auditing for login events and then parse the logs or enable a login script that will write this information to a database for you.

The latter is the better solution in my opinion as it will let you easily generate whatever reports you want.

Either way I feel PowerShell is not the right tool for the job. I would use a VBScript Login Script to get the job done.

Code:
Dim WSHNetwork
Set WshNetwork = CreateObject("WScript.Network")
strUserName = WSHNetwork.UserName

'Call the function to write the username and current date/time 
'to our database table called loginRecorder, with the fields 
'user_name (VARCHAR) and login_date (DATETIME).
RecordLogin strUserName

Function RecordLogin(strUserName)
	Dim dbConnection
	Set dbConnection = CreateObject("ADODB.Connection")
	dbConnection.Open "Provider=SQLOLEDB.1;Data Source=myServerName;Initial Catalog=myDatabaseName";"myUserName";"myPassword"
	dbConnection.Execute "INSERT INTO loginRecorder (user_name, login_date) VALUES ('" & strUserName" & ", Now())"
	Set dbConnection = Nothing
End Function

If you don't have SQL you can download the free SQLExpress from Microsoft.com.


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
On the flipside, if you have PowerShell on the SBS box, you could certainly use it to grab data from the eventlogs (once auditing of login events is enabled, as Mark mentioned).

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top