gpt4 book ai didi

powershell - 在 Where-Object 条件之后获取第一个值

转载 作者:行者123 更新时间:2023-12-02 23:07:28 32 4
gpt4 key购买 nike

给出以下命令如何仅获取 where 之后的第一个值健康)状况?

Get-WinEvent -FilterHashtable @{Logname = 'Security';EndTime=$Time; ID = 5379} |
select id , TimeCreated, @{ n='USER'; E ={ $_.Properties[1].Value}} |
where USER -notlike 'condition'

我试过 -MaxEvents 1-First 1但这仅适用于 Select-Object , 不适用于 where .

最佳答案

将您的结果通过管道传送至 Select-Object -First 1像这样:

Get-WinEvent -FilterHashtable @{Logname = 'Security';EndTime=$Time; ID = 5379} |
Select-Object Id , TimeCreated, @{ n='USER'; E ={ $_.Properties[1].Value}} |
Where-Object { $_.USER -notlike 'condition' } |
Select-Object -First 1

关于powershell - 在 Where-Object 条件之后获取第一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58861008/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com