Microsoft ISE v PS Studio Output - any thoughts?

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Andras
Posts: 31
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Thu May 14, 2015 3:27 pm

Microsoft ISE v PS Studio Output - any thoughts?

Post by Andras »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2017, Version 5.4.145
32 or 64 bit version of product:64
Operating system:Windows 7 Enterprise
32 or 64 bit OS:64

*** Please add details and screenshots as needed below. ***

I am running the below command via the Powershell ISE which IMHO is correctly sorting:

Get-WinEvent -LogName system -ComputerName computer1 | Where-Object {$_.ID -eq '45058'} | sort -Property $_.TimeCreated -Descending

Output: (Shortened)
TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
23/10/2017 1:21:54 PM 45058 Information A logon cache entry
23/10/2017 1:19:34 PM 45058 Information A logon cache entry
23/10/2017 10:56:26 AM 45058 Information A logon cache entry
19/10/2017 2:55:38 PM 45058 Information A logon cache entry
23/03/2017 11:42:32 AM 45058 Information A logon cache entry

If I run the exact same command in either the PS Studio shell or the script console the output I receive is:

TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
19/10/2017 2:55:38 PM 45058 Information A logon cache entry for user
23/03/2017 11:42:32 AM 45058 Information A logon cache entry for user
23/10/2017 10:56:26 AM 45058 Information A logon cache entry for user
23/10/2017 1:21:54 PM 45058 Information A logon cache entry for user
23/10/2017 1:19:34 PM 45058 Information A logon cache entry for user

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Microsoft ISE v PS Studio Output - any thoughts?

Post by davidc »

The issue seems to be in the Sort-Property call. Instead of $_.TimeCreated it should be just TimeCreated.

Code: Select all

Get-WinEvent -LogName system -ComputerName computer1 | Where-Object {$_.ID -eq '45058'} | sort -Property TimeCreated -Descending
David
SAPIEN Technologies, Inc.