# remote pc forensics

**URL:** <https://forums.powershell.org/t/remote-pc-forensics/14745>\
**Category:** PowerShell Help\
**Created:** [July 31, 2020, 7:19am UTC](https://forums.powershell.org/t/remote-pc-forensics/14745 "2020-07-31T07:19:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstump1972](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@jstump1972](https://forums.powershell.org/u/jstump1972)\
**Post date:** [July 31, 2020, 7:19am UTC](https://forums.powershell.org/t/remote-pc-forensics/14745/1 "2020-07-31T07:19:08Z")

</div>

I need to gather security events below on remote pc, save it to c:\temp on my machine in a nice csv format for each entry and list computer name, event id, username, date and time of event.

windows logon event id - 4624  
windows logoff event id - 4634  
windows lock event id - 4800  
windows unlock event id - 4801

my current script does not seem to be working very well and need assistance please. I need the full details of the event in the capture for HR\Legal to include client name, date\time, and user name info

$computers=get-content c:\temp\computers-to-investigate.txt  
foreach($computer in $computers)  
{  
Get-EventLog Security -ComputerName $computers | Where {$\_.InstanceID -like “4800”} | Select $UserProperty | FT  
}

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 31, 2020, 7:56am UTC](https://forums.powershell.org/t/remote-pc-forensics/14745/2 "2020-07-31T07:56:42Z")

</div>

jeremy, welcome to [Powershell.org](http://Powershell.org). Please take a moment and read the very first post on top of the list of this forum: [Read Me Before Posting! You’ll be Glad You Did!](https://powershell.org/forums/topic/read-me-before-posting-youll-be-glad-you-did).

When you post code, error messages, sample data or console output format it as code, please.  
In the “ **Text** ” view you can use the code tags “ **CODE** ”, in the “ **Visual** ” view you can use the format template “ **Preformatted** ”. You can go back edit your post and fix the formatting - you don’t have to create a new one.  
Thanks in advance.

What you’re asking for is almost impossible. Most event log entries are way to complex to be displayed in a simple table on the console. Run the following code on your pc to see what I mean:

```auto
$FilterHashtable = 
@{
    LogName = 'Security'
    ID = 4624, 4634, 4800, 4801
}
Get-Winevent -FilterHashtable $FilterHashtable -MaxEvents 1 | Select-Object -Property *

```

You use a loop to iterate over a list of computers but in your loop you do not use a single computer - **$computer**. Instead you use the list - **$computers**. So you query the complete list for each and every single computer again and again and again. 😉

You should not use Get-Eventlog anymore. Instead use the new Get-WinEvent. Try this as a starter:

```auto
$ComputerList = get-content c:\temp\computers-to-investigate.txt
foreach ($ComputerName in $ComputerList) {
    $FilterHashtable = 
    @{
        LogName = 'Security'
        ID = 4624, 4634, 4800, 4801
    }
    Get-Winevent -FilterHashtable $FilterHashtable -ComputerName $ComputerName | Select-Object -Property $UserProperty
}

```

BTW: What is in your variable **$UserProperty**?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:29pm UTC](https://forums.powershell.org/t/remote-pc-forensics/14745/3 "2024-05-16T20:29:08Z")

</div>

Closed on May 16, 2024, 8:29pm UTC


