简体   繁体   中英

Powershell: Run script as administrator causes infinite execution

I am completely new to Powershell. Found a script online for updating Windows, and want to run it as administrator. Have a script that starts a new session and calls that script from a network share:

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

The problem is that it keeps running the script and opening new windows infinitely. I have searched the Internet and could not find anything specific to my issue. How do I run my script to call the Windows Update script once and prevent it from executing infinitely?

Why are you using PowerShell, to call PowerShell, to run PowerShell?

In .cmd:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM