You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell脚本设置TLS12并调用UpdateView.exe时出现命令未找到错误的技术咨询

解决PowerShell中执行TLS设置与外部程序调用的错误问题

这个错误的核心原因是你误用了&调用操作符的语法:你把PowerShell语句和外部程序调用打包成了一个字符串,&会把整个字符串当作单个命令名称去系统里查找,而不是解析执行里面的PowerShell代码+调用程序。

修正方案(推荐分步骤写法,更清晰安全)

把TLS设置和外部程序调用拆分成独立步骤,先完成TLS配置,再调用UpdateView.exe:

Show-Message -Message "Step 1a: Create groups and adding users to it"

# 单独设置TLS 1.2(这是PowerShell语句,不需要用&调用)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# 调用外部程序,注意$HelperPath要确保有有效值,避免路径变成\UpdateView.exe
& "$HelperPath\UpdateView.exe" "true" $Username $Password

If ((Get-Content $ErrorLogFile) -ne $Null) {
    Show-Message -Message "Creating group and adding users to it failed" -Type ([MessageType]::Failure)
    RevertAll $ScriptDirectory 1
    return
}

额外注意事项

  • 错误提示里出现了\UpdateView.exe,说明你的$HelperPath变量可能为空或者未正确赋值,一定要检查这个变量的取值,确保路径完整有效。
  • 如果一定要把逻辑写在一块,也可以用脚本块的方式(但可读性不如分步骤):
Show-Message -Message "Step 1a: Create groups and adding users to it"
& {
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    & "$HelperPath\UpdateView.exe" "true" $Username $Password
}

内容的提问来源于stack exchange,提问作者John John

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 00:42:39