我目前使用 powershell 脚本遇到安装问题。我可以从命令行在主机 B 上毫无问题地运行脚本。但是当我尝试远程启动它时,脚本无法创建日志文件(我监控它以查看何时需要将密码发送到命令行)。错误在最底层......
我从主机 A 启动安装程序(请参阅下面的命令)。它远程执行主机 B 上的 powershell 脚本 cognosInstall.ps1。脚本代码在底部。它开始复制文件并开始安装,但由于某种原因,它在创建日志文件时出现问题。我检查了 HostB 上的本地目录,也没有找到该文件。
主机 A(数据收集器):触发远程执行安装 IBM Cognos 的 powershell 脚本。
$s=new-pssession -computername HostB -credential $creds
invoke-command -session $s {$filename=Split-Path c:\temp\auto-install\*stats*.iso -leaf -resolve;echo $filename;}
invoke-command -session $s {c:\temp\auto-install\cognosInstall.ps1 $filename;}
主机 B(正在安装 Cognos):
#Open a command window
invoke-item C:\Windows\System32\cmd.exe
start-sleep -s 2
# Write output of install command to file
select-window cmd |send-keys "c:\temp\cognos-install\cognos_install.bat c:\temp\cognos-install\cognos_mssql.ini C:\temp\IBM_Cognos_10.1.1_and_FP1 > c:\temp\Cognos_Install_log 2>&1 {ENTER}"
#check file for password prompt
do {
Start-Sleep -s 8;
write-output "Waiting for Password Prompt"
}
until (Select-string -Path c:\temp\Cognos_Install_Log -pattern Password )
select-window cmd |send-keys "Passwd123{ENTER}"
我得到的错误: 安装开始运行.....然后遇到这个问题......
Copying install config file to cognos-install directory
C:\temp\auto-install\cognos_mssql.ini
1 File(s) copied
Beginning of Cognos Install - wait for completion
Waiting for Password Prompt
Cannot find path 'C:\temp\Cognos_Install_Log' because it does not exist.
+ CategoryInfo : ObjectNotFound: (C:\temp\Cognos_Install_Log:Stri
ng) [Select-String], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Selec
tStringCommand