【发布时间】:2023-03-17 13:52:01
【问题描述】:
我在通过网络使用 PowerShell 进行搜索时遇到问题;程序在执行Get-ChildItem时卡住了。
# creating search string
$date = "*2018-01-10*"
$format = ".avi"
$toSearch = $date + $format
echo $toSearch
# Verifying A: drive to be disconnected
net use /d A: /y
# connecting Network drive to local drive A:
if (Test-Connection -ComputerName PROC-033-SV -Quiet) {net use A: \\PROC-033-SV\c$}
# getting list of directories to search on
$userList = Get-ChildItem -Path A:\users\*.* -Directory
# verifying list of directories prior to search
echo $userList
# searching through Network, on A:\Users\ subdirectories for $toSearch variable
Get-ChildItem -Path $userList -Include $toSearch -Recurse -Force
# *** HERE's where the program get stuck, it nevers stop searching
# it nevers reach pause
pause
有谁知道为什么Get-ChildItem 一直在循环并且永远不会停止?
我正在使用 PS v4 没有 -Depth 选项可用于 -Recurse 参数;我怀疑这可能是问题所在。
【问题讨论】:
-
你读过错误吗?这在我看来是预期的。
-
实际上正在工作,但需要很长时间......我想我需要更新到 V5 以使用 -Depth 以使其更快。这些文件是 5 个深度级别; \Users\AppData\Temp\FolderTarget
标签: powershell scripting powershell-4.0