【发布时间】:2021-07-05 12:53:43
【问题描述】:
以下命令旨在列出过期的用户帐户:
powershell -c "Get-LocalUser | Where-Object { $_.AccountExpires -le (Get-Date) -and $null -ne $_.AccountExpires } | Select-Object Name, AccountExpires"
直接在 PowerShell 上运行似乎运行良好,但是,当我通过 CMD 运行相同的命令时,它会给出以下错误:
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index').
我认为这个问题与 $null 参数有关,但我需要它来从输出中排除空白匹配项。有谁知道解决此错误的方法?还是不匹配空白输出的替代方法?
【问题讨论】:
标签: windows powershell command