Install MSI files on remote servers failes

This topic contains 9 replies, has 4 voices, and was last updated by Profile photo of Johan Hammarstrom Johan Hammarstrom 1 year, 10 months ago.

  • Author
    Posts
  • #22227
    Profile photo of Johan Hammarstrom
    Johan Hammarstrom
    Participant

    Hi admin,

    Shouldnt it be possible to install a msi file on a remote servers through powershell?
    When i run my "code" locally the installation works but when i put the code in a script block and using invoke-command nothing happens..

    Any ideas?

    Cheers
    Johan

    Invoke-Command -ComputerName $computer -ScriptBlock {
    $msi = "c:\Notifier\Notifier-Windows-9.5.2-2022.i386.msi"
    $arguments= ' /qn /l*v .\Notifier.log'
    Start-Process -file $localmsifile -arg $arguments -passthru | wait-process}

  • #22229
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Possible, yes. Straightforward, not necessarily. It depends entirely on what the MSI is trying to do – if it's raising any kind of interactive UI, or trying to access any non-local resources, it'll fail. A lot of MSIs also expect to have a user profile available to write to – e.g., directories, registry, etc. When you connect via Invoke-Command, you don't spin up a profile, and so that can cause the MSI to fail also. Not much workaround except rewriting the MSI itself to not have those requirements.

  • #22230
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    How does it fail? Does the MSI exist on the remote computer, or is that C:\ path referring to a file on the local machine?

  • #22231
    Profile photo of Johan Hammarstrom
    Johan Hammarstrom
    Participant

    Thanks for you super fast reply 🙂

    I will then try do solve this in some other ways.

    Cheers
    Johan

  • #22232
    Profile photo of Johan Hammarstrom
    Johan Hammarstrom
    Participant

    Dave,

    Yes the msi file exists on the server.
    Below is what im trying to run:

    $computername = Get-ADComputer -Filter 'name -like "kto-dmzapp-*"' |select -ExpandProperty name
    $msifile = "\\kto-mgmt-01\d$\app\Notifier-Windows-9.5.2-2022.i386.msi"

    foreach ($computer in $computername)
    {
    $destinationFolder = "\\$computer\C$\Notifier\"

    if (!(Test-Path -path $destinationFolder))
    {
    New-Item $destinationFolder -Type Directory
    }
    Copy-Item -Path $msifile -Destination $destinationFolder

    Invoke-Command -ComputerName $computer -ScriptBlock {
    $localmsifile = "c:\Notifier\Notifier-Windows-9.5.2-2022.i386.msi"
    $arguments= ' /qn /l*v .\Notifier.log'
    Start-Process -file $localmsifile -arg $arguments -passthru | wait-process}

    }

  • #22233
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Looks like you're pretty much doing everything right. Anything in the Notifier.log file?

  • #22238
    Profile photo of ian
    ian
    Participant

    Watch out for http://support.microsoft.com/kb/2918614. This broke our ability to install msi packages via posh remoting.

  • #22349
    Profile photo of Johan Hammarstrom
    Johan Hammarstrom
    Participant

    Hi, Thanks for your replies so far 🙂

    I have now changed my "code" a little bit.
    Now it works the way i want it except for one small issue... I have to be LOGGED IN on the servers!!!!

    If im not logged in to the servers my script copies the msi file to the temp folder as it should and then tries to start the install but fails.
    (10837 Error MsiInstaller Application 2015-02-04 15:10:38)

    If im logged on to the remote servers when i run my scripts from the mgmt server it works as planned. (The same account which runs the script from the mgmt server)
    All my servers are windows2012r2.

    Maybe this isnt a powershell issue?
    Advice?

    Cheers
    Johan

    ———–
    $computers = Get-ADComputer -Filter 'name -like "kto-targ*"' | select -ExpandProperty name

    foreach ($comp in $computers)
    {
    $destinationFolder = "\\$comp\d$\temp\"
    #This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
    if (!(Test-Path -path $destinationFolder))
    {
    New-Item $destinationFolder -Type Directory
    }

    $deploy = {
    Set-Location "d:\temp"
    & msiexec.exe /I Notifier-Windows-9.5.2-2022.i386.msi /quiet
    }

    Copy-Item -path \\kto-mgmt-01\d$\app\Notifier-Windows-9.5.2-2022.i386.msi -Destination \\$comp\d$\temp
    $session = New-PSSession -ComputerName $comp
    Invoke-Command -Session $session -ScriptBlock $deploy
    }

  • #22350
    Profile photo of Don Jones
    Don Jones
    Keymaster

    This isn't a PowerShell [b]problem[/b], no. The MSI is attempting to write to the local profile; when you're not logged in on the server, there isn't a profile for it to write to, and so it fails. There's not much you can do about that except repackage the MSI to not need a local session. It's probably trying to write icons to a Start menu folder or something.

  • #22353
    Profile photo of Johan Hammarstrom
    Johan Hammarstrom
    Participant

    Thanks Don.

    Makes sense,

    Cheers
    Johan

You must be logged in to reply to this topic.