core: 优化 powershell 查询

- 避免 wmic where 条件有空格时报错
- 减少 ForEach-Object 以提高速度
This commit is contained in:
bin456789
2026-04-25 23:16:53 +08:00
parent 6341c21d0b
commit e2a8be7bb7
2 changed files with 48 additions and 26 deletions

View File

@ -643,13 +643,12 @@ wmic() {
curl -Lo "$tmp/wmic.ps1" "$confhome/wmic.ps1"
fi
# shellcheck disable=SC2046
powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass \
-File "$(cygpath -w "$tmp/wmic.ps1")" \
-Namespace "$namespace" \
-Class "$class" \
$([ -n "$filter" ] && echo -Filter "$filter") \
$([ -n "$props" ] && echo -Properties "$props")
${filter:+"-Filter"} ${filter:+"$filter"} \
${props:+"-Properties"} ${props:+"$props"}
}
is_virt() {