Reputation: 25
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...
Upvotes: 3
Views: 4079
Reputation: 3
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
}
Upvotes: 0
Reputation: 25
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.
Upvotes: -1
Reputation: 1325
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.
Upvotes: 0