3

I'm trying to install a msi file on a remote server using powershell.

Server 1 is my build server and server 2 is my application server. When the build server finishes a buil, I want to trigger a powershell script to install the latest version to my application server.

I'm using the following command to create a session and execute the installation:

# Create session to Application Server
$Session = New-PSSession -Name <ApplicationServer> -ComputerName <ApplicationServer> -Auth CredSSP -cred OURDOMAIN\MyUser 

# Prepare expression and create script block
$Script = "Invoke-Expression 'msiexec /i <InstallerFile> /qn /L*v C:\Temp\install_fail.log'"
$ScriptBlock = [Scriptblock]::Create($Script)

# Execute in the session
Invoke-Command -ScriptBlock $ScriptBlock -Session $Session

# Clean up the session
Remove-PSSession $Session

The log has the following error (see attachment install_fail.log for full log)

MSI (s) (C4:1C) [17:08:05:333]: Note: 1: 1708 
MSI (s) (C4:1C) [17:08:05:333]: Product: WindowsService1 -- Installation failed.

MSI (s) (C4:1C) [17:08:05:335]: Windows Installer installed the product. Product Name: WindowsService1. Product Version: 8.0.0.0. Product Language: 1033. Manufacturer: MyCompany. Installation success or error status: 1603.

When I start a session on the powershell command promt and execute the installation the installation succeeds (see attachment install_success.log for full log): ENTER-PSSession -ComputerName Invoke-Expression 'msiexec /i /qn /L*v C:\Temp\install_success.log' exit

When I print whoami in both cases it returns OURDOMAIN\MyUser.

Microsoft lists the following regarding the 1603: (http://support.microsoft.com/kb/834484) The folder that you are trying to install the Windows Installer package to is encrypted.

The folder is not encrypted

The drive that contains the folder that you are trying to install the Windows Installer package to is accessed as a substitute drive.

The drive is a partition on the harddisk of the server

The SYSTEM account does not have Full Control permissions on the folder that you are trying to install the Windows Installer package to. You notice the error message because the Windows Installer service uses the SYSTEM account to install software.

The SYSTEM account has Full Control on the drive and all folders.

Please advise...

6
  • You usually use -Auth CredSSP when running into a second hop problem. Is the install file back on the build server? If so, as an experiment, copy the install file to the application server so the file is local and try again without -Auth CredSSP. Commented Jan 28, 2014 at 15:30
  • Thank you for your answer, but I'm sorry to say that it did not solve the 1603 issue. Commented Jan 29, 2014 at 11:11
  • And if you log directly (or via RDP) into the server with your credentials and run the msi command line to install - does that work? Just trying to figure out if the issue is PS remoting related. Commented Jan 29, 2014 at 18:17
  • When I login using ENTER-PSSession -ComputerName Invoke-Expression 'msiexec /i /qn /L*v C:\Temp\install_success.log' exit it installs without a problem Commented Jan 30, 2014 at 9:02
  • Where is the MSI file located in both instantiations? Is the MSI file local in both cases? On a file share? Also, why use Invoke-Expression? You can run msiexec directly from PowerShell. Commented Jan 30, 2014 at 14:56

3 Answers 3

0

Have you tried using PSEXEC? or are you using powershell for a reason? I find that easier for remote installs than trying to go through powershell.

Just PSEXEC into the server CMD. Copy the files locally then run MSIExec to install.

Sign up to request clarification or add additional context in comments.

3 Comments

I switched to a different approach. Thanks for your time and thoughts.
@Seppie: Would you mind explaining your "different approach" so other people (like me) can also solve this problem? You can actually write an answer to your own question and even mark it as the solution to the problem.
@AudioDroid, see my answer below.
0

I encountered the same issue when attempting to use PowerShell to remotely connect and execute 'msiexec' for software installation. Instead, I used cmd. Here's an example:

$RemoteServers = 'server1','server2','server3'

foreach ($RemoteServer in $RemoteServers) {
    $Session = New-PSSession -ComputerName $RemoteServer
    $CommandToRun = "cmd /c msiexec.exe /qn /i C:\Windows\Temp\mymsi.msi /l*v C:\log.txt"

   Invoke-Command -Session $Session -ScriptBlock {
        param($Command1, $Command2)
        Invoke-Expression -Command $Command1
    } -ArgumentList $CommandToRun 

    # Close the PSSession
    Remove-PSSession $Session
}

Comments

-1

I ended up writing a second PowerShell script that runs on the server watching a specific folder for new msi files. The script runs the first script that actually performs the installation tasks.

1 Comment

To anyone considering this method be careful of who has write access to the special folder with the msi's. Whoever has that access has full control over the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.