PS C:\> 1,3,2,3,2,1,2,3,4,7 | Sort-Object 1 1 2 2 2 3 3 3 4 7 PS C:\> 1,3,2,3,2,1,2,3,4,7 | Sort-Object -Unique 1 2 3 4 7 |
This may be perfectly fine, but depending on your event log, you may also get duplicate entries.复制代码
- Get-EventLog -LogName System -EntryType Error -Newest 40 | Sort-Object -Property InstanceID, Message | Out-GridView
You will no longer see more than one entry with the same InstanceID AND Message.复制代码
- Get-EventLog -LogName System -EntryType Error -Newest 40 | Sort-Object -Property InstanceID, Message -Unique | Out-GridView
So bottom line is: Sort-Objects parameter -Unique can be applied to multiple properties at once.复制代码
- Get-EventLog -LogName System -EntryType Error -Newest 40 | Sort-Object -Property InstanceID, Message -Unique | Sort-Object -Property TimeWritten -Descending | Out-GridView
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |