where-...

问题描述 投票:0回答:1
Stick

at the end of your pipeline to

    $Paths = 'C:\' , 'P:\' , "\\fril01\ufr$\$env:username"

    $torEXE = Get-childitem -path $paths -recurse -Exclude $ExcludePaths -erroraction 'silentlycontinue'  | where-object {$_.name -eq "Tor.exe"}

    if ($torEXE.Exists) {$answer = 1}

make it stop executing

after the first
windows powershell directory get-childitem
1个回答
2
投票

|Select-Object -First $N我有这样的代码。检查文件tor.exe, 但你可以看到这个检查可能需要一些时间. 有可能在最初的几秒钟就找到tor.exe,但会继续检查所有的路径. 我想让它在找到tor.exe后立即停止,而不是继续搜索它. $N Select-Object我有这样的代码。$Paths = 'C:\' , 'P:\' , "\fril01\ufr$\$env:用户名" $torEXE = Get-childitem -path $paths -recurse -Exclude $ExcludePaths -erroraction 'silentlycontinue'。

© www.soinside.com 2019 - 2024. All rights reserved.