我正在从bat文件运行Powershell脚本。这两个文件放在网络服务器上,我试图通过访问网络服务器文件夹从我的机器上在网络服务器上运行这些文件。我收到以下错误:在网络机器上运行powershell脚本
CMD doesn't support UNC paths as current directories.
当我执行批处理文件,它会尝试从路径
C:\Windows\System32
不会有不同于bat文件设置读取当前目录下的脚本文件。
当我在本地机器上运行时,此脚本和bat文件正常工作。
我试着在谷歌上找到这个,可能的解决方案需要更改网络服务器上的一些设置,这在我的情况下是不可能的。
对此有什么可能的解决方案?
我使用的PowerShell 2.0
这里是我的bat文件来运行PowerShell脚本
setlocal & pushd .
:getting current directory
cd /d %~dp0
Powershell.exe Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Powershell.exe . '%CD%\Hotfix-Automation-Installer.ps1' crpt
exit /B
“-ExecutionPolicy搭桥”的工作,但我更喜欢“下RemoteSigned”,然后添加特定的UNC路径Intranet区域运行未签名来自这些位置的脚本。请参阅此处的选项#2:http://setspn.blogspot.com/2011/05/running-powershell-scripts-from-unc.html –