运行 powershell 脚本远程使用 PsExec 更改注册表中的 MySQL ODBC 设置

Run powershell scripts remotely using PsExec to change MySQL ODBC settings in the registry

我正在尝试 运行 在一堆计算机上使用 PsExec 的 powershell 脚本。

PsExec64.exe -i \comp-int-tst-03 -u domain\un.admin -p asdfqw /accepteula PowerShell ChangeODBCServer.ps1

这是我得到的错误

PowerShell exited on comp-int-tst-03 with error code 1.

这是脚本

if(Test-Path HKLM:\SOFTWARE\ODBC\ODBC.INI\user){
Set-Location HKLM:\SOFTWARE\ODBC\ODBC.INI\user
$server = (Get-ItemProperty HKLM:\SOFTWARE\ODBC\ODBC.INI\user).SERVER
if($server-eq "user"){
Set-ItemProperty . SERVER "user.app"
"Set1"}
}
if(Test-Path HKLM:\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\user){
Set-Location HKLM:\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\user
$server = (Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\user).SERVER
if($server-eq "user"){
Set-ItemProperty . SERVER "user.app"
"Set2"}
}

有什么办法让它继续吗?或者至少看看为什么它不起作用?脚本 运行 在本地没问题。

好的所以只是尝试了这个并且效果很好。 pc-host 是我试图从中 运行 它的机器。 C$ 是我可以作为管理员共享访问的本地磁盘。

PsExec64.exe \comp-int-tst-03 -u crc\un.admin -p asdfqw /accepteula PowerShell -noninteractive -File \pc-host\C$\Users\u.name\ChangeODBCServer.ps1