Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell to look for logon on a remote PC

Posted on 2013-10-30
2
Medium Priority
?
302 Views
Last Modified: 2013-11-17
I need a fast and efficient way to look for the logon event for a specific user, lets call them janedoe, on a list of remote PC's.

To explain further, there are 4 PC's and I want to look at the event logs of those every day to see if janedoe logged on to any of those devices.

I would rather not have to connect to the event viewer for each of these PC's every day, so I was hoping to script it.  I figure Powershell can do this.

Can anyone help out?
0
Comment
Question by:southpau1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39612709
Try with Get-EventLog..
GC C:\Server.txt | % {
Get-EventLog -LogName security -InstanceId 4624 -ComputerName $_ -After (Get-Date).Adddays(-1) | 
    Select-Object -Property MachineName,timegenerated,
    @{n="AccountName";e = {$_.replacementstrings[5]}},
    @{n="AccountDomain";e = {$_.replacementstrings[6]}},
    @{n="WorkstationName" ; e = {$_.replacementstrings[13]}} |
    ? {$_.AccountName -eq "janedoe"}
} | Export-Csv C:\Report.csv -NTI

Open in new window

C:\Server.txt format..
ServerA
ServerB
ServerC

Open in new window

0
 
LVL 7

Author Closing Comment

by:southpau1
ID: 39654498
Looks great, thanks!
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question