Powershell:以管理员身份运行脚本会导致无限执行

Powershell:以管理员身份运行脚本会导致无限执行,powershell,Powershell,我对Powershell完全陌生。联机找到用于更新Windows的脚本,并希望以管理员身份运行该脚本。具有启动新会话并从网络共享调用该脚本的脚本: PowerShell.exe -noprofile -command "&{Start-Process PowerShell -ArgumentList '-noprofile -file \\path\to\networkshare\00_WindowsUpdate.ps1' -Verb RunAs}" 问题是它一直在运行脚本并无限地打

我对Powershell完全陌生。联机找到用于更新Windows的脚本,并希望以管理员身份运行该脚本。具有启动新会话并从网络共享调用该脚本的脚本:

PowerShell.exe -noprofile -command "&{Start-Process PowerShell -ArgumentList 
'-noprofile -file \\path\to\networkshare\00_WindowsUpdate.ps1' -Verb RunAs}"

问题是它一直在运行脚本并无限地打开新窗口。我在互联网上搜索过,没有找到任何与我的问题相关的东西。如何运行脚本来调用Windows Update脚本一次并防止其无限执行?

为什么要使用PowerShell来调用PowerShell,运行PowerShell

在.cmd中:

RUNAS /noprofile /user:domain\user "powershell -ExecutionPolicy Bypass -Command '& \\Path\update.ps1'"

00|u WindowsUpdate.ps1的内容是什么?第1行:“导入模块\\路径\到\PSWindowsUpdate”第2行:“获取WUSTALL-WindowsUpdate-IgnoreUserInput-Acceptell-IgnoreReboot-Verbose | Out文件C:\Windows\Temp\PSWindowsUpdate.log”,如果在cmd提示符下也尝试过,仍然无限执行并不断打开新窗口。@PatrykChristopher这听起来像是您试图运行的脚本的错误。这就是我所猜测的。我尝试了一个测试脚本,其中它为windows update导入了一个模块,然后我执行了一个检查更新历史的基本命令。可能是它一直在导入模块吗?@PatrykChristopher没有源脚本就无法知道。这是一组不同的脚本,您需要在其中导入模块以使其可用。