New to Powershell

This topic contains 4 replies, has 3 voices, and was last updated by  Yuan Li 2 years, 4 months ago.

  • Author
  • #34875

    Stephen Jones

    Hello all,

    I'm working on installing Java on remote hosts and have the basis for a script. However, I'm having problems with installing java remotely either by invoke-command or enter-possession. I use the following line to install Java successfully locally but so far the command will complete remotely with no errors but does not install java. Any ideas on how to troubleshoot this?

    Start-Process -FilePath c:\temp\java.exe -ArgumentList "/s" -PassThru -Wait

  • #34880

    Matt Bloomfield

    Does the process start?

    If it starts, enable logging with the arguments /L

    FWIW, in the enterprise, you're probably better off deploying the MSI.

  • #34882

    Yuan Li

    Hi Stephen

    Try this and it should work

    Invoke-Command -ComputerName $computerName -ScriptBlock { Start-Process -filepath "c:\temp\jre8.exe" -argumentlist "/s /L c:\temp\install.txt" -Verb runas -PassThru -Wait }

  • #34908

    Stephen Jones

    Thanks for the responses Matt & Yuan!! I ran the following command:
    Invoke-Command -ComputerName cpu -Credential dom\acc -ScriptBlock { Start-Process -filepath "c:\temp\java.exe" -argumentlist "/s /L c:\temp\install.txt" -Verb runas -PassThru -Wait }

    The command executes and responds :
    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName PSComputerName
    ——- —— —– —– —– —— — ———– ————–
    0 2 50864 152 54 0.05 1164 java cpu

    However, there is no log file and java does not install.

  • #35009

    Yuan Li

    Hi Stephen,

    I tried it on my windows 2012 R2 server remotely and it was working. The java is installed and log was created.

    Do you use an admin account ? Does this account have write permission on your c:\temp folder?

You must be logged in to reply to this topic.