PS H:\> Invoke-Command -computername SERVERNAME { Get-ChildItem -path E:\dfsroots\datastore2\public} | Where-Object {{ $_.e
xtension-match "xls" -or $_.extension-match "xlk" } -and { $_.creationtime -ge "06/01/2014"}}
以上是我的代码示例。我正在尝试远程运行此PowerShell代码并使其返回创建日期在2014年6月1日或之后的所有.xls和.xlk文件。运行此代码时,它开始输出该远程位置中的所有文件夹。如果我只比较两个东西,如下所示:PS H:\> Invoke-Command -computername SERVERNAME { Get-ChildItem -path E:\dfsroots\datastore2\public} | Where-Object { $_.extension-match "xls" -and $_.creationtime -ge "06/01/2014"}
只有在那个日期之后创建的 xls 文件才会显示。这是怎么回事?我需要使用除了嵌套 -and
和 -or
语句之外的其他内容吗?
Where{($_.Extension -Match "xls" -or $_.Extension -Match "xlk") -and $_.CreationTime -ge "06/01/2014"}
。 - TheMadTechnician