从多个远程服务器搜索特定文件类型的文件

时间:2014-07-30 10:58:54

标签: powershell command

你能帮我完成我的小命令,我用它来搜索来自区域内150台服务器的远程服务器的文件

Invoke-Command -ComputerName (Get-Content F:\Serverlist.txt) -ScriptBlock {dir c:\ -Recurse -File | where {$_.Extension -eq ".pst"} |select Length,LastAccessTime,Name,@{n='Path';e={$_.fullname}},@{n='Owner';e={$_.getaccesscontrol().owner}}} |Export-Csv F:\files.csv -NoTypeInformation

我在这里搜索C盘中多个服务器的.PST文件,我想在上面的命令中包含其他驱动器F.

1 个答案:

答案 0 :(得分:1)

DirGet-ChildItem的别名,您可以使用Get-Alias dir查看此内容。

如果您使用Get-Help Get-ChildItem -Full查看帮助,则会看到-Path接受多项输入:

-Path <String[]>
    Specifies a path to one or more locations.

所以我认为解决方案是替换:

dir c:\使用此Get-ChildItem C:, F: