远程执行和控制批处理文件

时间:2017-04-20 14:32:53

标签: batch-file powershell-v2.0

我正在编写一个脚本来远程执行并向批处理文件提供输入,以便通过PowerShell更改ActiveDirectory中的计算机的OU。 我到目前为止的脚本:

$domain = "[DOMAIN]"
$User = Get-Credential
Start-Process "NETWORK_FILEPATH\powershell.bat"
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM
Enter-PSSession -ComputerName [IP] -Credential $User
C:\AUTO_SETUP.bat
"\\hd\it\Unattend-Domain\OU-Script\scriptdisallow.ps1"

我已经从StackOverflow上的各种文章编译了这个的远程执行部分,但每次运行时我仍然会收到错误:

C:\AUTO_SETUP.bat is not recognized as the name of a cmdlet, function, 
script file, or operable program

有关如何修复我的内容或更好的方法的任何想法?我需要能够捕获cmd文件的输出并通过PowerShell窗口传递它,因为我将从域上的另一台计算机运行。远程执行此操作的原因是我们只有一台计算机在域中具有activedirectory模块。谢谢!

0 个答案:

没有答案
相关问题