0

I am using powershell and WMI to install msi package on remote machine, and getting return value 3 when trying to install. It's strange, because before installation my script checks for installed product, and if it is present uninstalls it. Uninstall is completeing successfully.

I googled for return value 3 of install method - but there is nothing.

Do anyone know something about this return code?

Thanks.

EDIT: Here is the code.

function InstallPJM([string]$packagePath, [string]$machineName)
{
   Write-Host “Installing from $packagePath on $machineName”

    #1   
    (Get-WMIObject -ComputerName $machineName -List | Where-Object -FilterScript {$_.Name -eq "Win32_Product"}).Install($packagePath)

    #$product = [WMICLASS]“\\$machineName\ROOT\CIMV2:win32_Product”

    #2
    #$product.Install($packagePath, "", "True")    
}

Function call:

InstallPJM "C:\PJM7DeploymentFolder\Pjm7.msi" "MachineName"

I tried 2 ways (numbered strings): each of them gives ReturnValue 3

Sergey
  • 537
  • 6
  • 18
  • Could you post some of your code so we can see how you are doing it? – David Martin May 31 '13 at 07:20
  • What msi package are you installing? – David Brabant May 31 '13 at 07:24
  • I can see a couple of possible issues. C:\PJM7DeploymentFolder\Pjm7.msi should be local to the machine (or via UNC). "True" should be defined as boolean $true not string. – David Martin May 31 '13 at 08:25
  • "Return value 3" is a common message in MSI logs when an action has failed. You should enable logging (http://support.microsoft.com/kb/223300/en-GB) and examine the installer logs. – JohnL May 31 '13 at 09:00
  • Once you have the logfile, search for 'value 3' the cause of the error is usually a few lines above that. – David Martin May 31 '13 at 09:09
  • @DavidMartin, C:\PJM7DeploymentFolder\Pjm7.msi is local path on server, from which i trying to deploy app, but thank you for idea. – Sergey May 31 '13 at 09:22
  • @JohnL, I enabled logging as said in article. But when i execute script no logfile is created. When i execute msi manually log file successfully creates. – Sergey May 31 '13 at 09:45
  • How did you enable it? By editing the registry or using the Fix-It buttons? You may have edited the x64 area of the registry and you're running an x86 installer, or vice versa. Try adding the Logging entry under HKLM\Software\Microsoft... and also HKLM\Software\Wow6432Node\Microsoft... – JohnL May 31 '13 at 09:50
  • Oh, and also make sure you're checking the %temp% directory for the right user as well. Note that UAC can cause the log file to be dropped in the %temp% folder for the admin user whose details you enter into the UAC prompt, rather than your own %temp% folder – JohnL May 31 '13 at 10:01
  • @JohnL, I enabled logging in x86 and x64 nodes, but no log was generated. Returning to return value 3, can it be caused by such situation: I need to deploy software from server to client pc. On server i am running PowerShell from Admin account. This account is added to Administrators group in machine, where software will be deployed. When i run script, on remote machine some user is logged (but not admin). But if run script when admin is logged on remote machine installation succedes. Main question is: can i install software from admin account on server to remote machine for different user. – Sergey May 31 '13 at 10:51
  • The fact that no log was created (assuming the logging is set up correctly and you're looking in the right place for the log) suggests it's not actually launching the install. On the other hand, given what you are trying to achieve, you probably need to start a remote session on the target machine, and run your code in the context of that session – JohnL May 31 '13 at 13:08
  • Please keep in mind that [`Win32_Product` should be avoided entirely](https://stackoverflow.com/questions/71575378/powershell-for-software-inventory/71576041#71576041) and alterative software inventory and management methods should be used instead. – codewario Mar 24 '22 at 14:33

1 Answers1

0

In my case ReturnValue=3 was because I passed a relative path to the MSI from PowerShell. Wrapping in a Resolve-Path made it work.

YMMV

piers7
  • 4,174
  • 34
  • 47