0

I am currently stuck with an installation issue using a powershell script. I can run the script without any problem on Host B from command line. But when I attempt to launch it remotely, the script is not able to create the log file (which I monitor to see when I need to send the password to the command line). The error is at very bottom...

I launch the installer from Host A (see commands below). It remotely executes the powershell script cognosInstall.ps1 on Host B. The script code is at bottom. It begins to copy files over and kick-off the installation, but for some reason it has a problem with creating the log file. I check local directory on HostB and do not find the file either.

Host A (data collector): Triggers remote execution of powershell script which installs IBM Cognos.

$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;}

Host B (Cognos is being installed on):

#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}"

Error I am getting: Install starts to run..... then hits this issue.....

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
SteveS
  • 11
  • 1
  • Try and run `Enter-PSSession -computername HostB -credential` and then perform your HostB commands. This should shed more light on what's going on. – Raf Sep 15 '14 at 13:00
  • You're using two custom functions on the line where it looks like you're trying to create your txt file. Tough for anyone to assist with that... – Noah Sparks Sep 15 '14 at 13:00
  • What @NoahSparks said. Also, try giving the file an extension, third party software may have an implicit assumption anything without an extension is a folder. – JNK Sep 15 '14 at 13:02
  • @NoahSparks... I should have mentioned... I have the WASP plugin installed... it allows me to select the window and then send keys to the selected window... – SteveS Sep 15 '14 at 13:31
  • @JNK: I modified the filename to Cognos_Install.log and re-ran. I get same error message. Am I going about this the wrong way? Is there a better option for me to trigger the install, detect password prompt, and then submit the password? – SteveS Sep 15 '14 at 13:38
  • @SteveS I guess I'm confused about why you're using CMD for this too? – JNK Sep 15 '14 at 13:40
  • I'm also not sure that your window commands will work correctly in a remote session...There may be no actual window for it to select. – JNK Sep 15 '14 at 13:42
  • @Raf: When I run manually in powershell window, I get same results, session established, script begins to run, exits with same error...and no file created in appropriate directory. – SteveS Sep 15 '14 at 13:44
  • Create an empty `C:\temp\Cognos_Install_Log` file and see if the script eventually progresses..if the issue is delay in creating log file that should do the trick. – Raf Sep 15 '14 at 13:47
  • @Raf: I tried that already. The file remains empty.The script just hangs waiting for password prompt which never arrives. – SteveS Sep 15 '14 at 13:55
  • Have you tried to do get-process on the remote machine to see whether the install process created by the batch file is actually started? If this is an installer you should also be aware of UAC and other things that might interfere with process creation on a remote machine. – Stephen Connolly Sep 15 '14 at 21:48
  • Ok, in case someone wants closure on this issue... I could not find solution to problem. So I reworked everything. I created the cognoss user ahead of time (if not there already). I took this part out of cognos installation script. This allowed me to then run the cognos install script directly from the powershell prompt. So I did not have to use send-keys or redirect output to file. – SteveS Sep 19 '14 at 14:16

0 Answers0