powershell script installs an application using msiexec and was closed

Christoph_H 20 Reputation points
2023-04-27T09:52:06.4833333+00:00

We have a powershell-install script, that installs automatically our application-msi at a Windows Server 2019.

This script worked fine. For a few months, the script/powershell-session has been aborted during execution of the msiexec command. The installation with msiexec completes successfully, but the powershell-script is closed.

Here the part of the powershell-script:

try {
	Write-Host "[+] Start-Process msiexec for application-installation..."
	Start-Process "msiexec" -ArgumentList @("/i $msiFile","/passive","APPPOOL=$targetAppPool","WEBSITE=$webSiteName","WEBSITE_PORT=$webSitePort","IISROOT=$wwwrootFolder") -Wait
	# --- here, the powershell-execution was interrupted and also no exception was occured ---
	Write-Host "[:] msiexec has exited properly."
} catch {
	Write-Host "[#] An exception occured during install..."
}

The eventlog on the server:

User's image

And the warning shows:

User's image

I did not find any solutions until now.

Can anyone help me to find out, what's the reason for this issue?

Thanks,

Christoph

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2023-04-28T13:33:12.81+00:00

    It would appear that something else is the script is opening a handle to something that the MSI restart manager wants to update, and it is terminating the Powershell process.

    What does the script do before it hits the try/catch portion that you posted? Can you simplify the script to just call msiexec?

    Try this, download handle.exe and put it on the server somewhere.

    https://learn.microsoft.com/en-us/sysinternals/downloads/handle

    In the script add a transcript (start-transcript) if you haven't already added one. Then right before you call msiexec, call handle.exe. That will show all handles for the current Powershell pid.

    c:\utils\handle.exe  -accepteula -p $pid
    
    

    Do you see any files/folders/registry in the transcript that are related to what the MSI might update?

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2023-04-27T13:56:25.3333333+00:00

    Add a logging option to msiexec and then analyze the file to see what error occurred.

    User's image

    0 comments No comments

  2. Christoph_H 20 Reputation points
    2023-04-28T06:43:59.19+00:00

    I added the logging option as you suggested ( /l*v log.txt ). In the logfile i found the entry:

    Will attempt to shut down and restart applications because the UI does not display any modal dialogs.
    Successfully shut down all applications in the service's session that held files in use.
    Successfully shut down all applications that held files in use.
    

    We have already tried a server-restart (several times) - but with no success.

    Here is the detailled log entry - the timestamp as the powershell-session was shutdown was 07:48:11:

    Action start 07:48:07: InstallValidate.
    MSI (s) (34:6C) [07:48:07:156]: Note: 1: 2205 2:  3: _RemoveFilePath 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 1402 2: HKEY_CLASSES_ROOT\.ServerConfigurator 3: 2 
    MSI (s) (34:6C) [07:48:11:000]: PROPERTY CHANGE: Modifying CostingComplete property. Its current value is '0'. Its new value: '1'.
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: BindImage 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: ProgId 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: PublishComponent 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: SelfReg 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: Extension 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: Font 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: Class 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2205 2:  3: TypeLib 
    MSI (s) (34:6C) [07:48:11:000]: Note: 1: 2727 2:  
    MSI (s) (34:6C) [07:48:11:047]: RESTART MANAGER: Will attempt to shut down and restart applications because the UI does not display any modal dialogs.
    MSI (c) (84:94) [07:48:11:047]: RESTART MANAGER: Session opened.
    MSI (s) (34:6C) [07:48:11:110]: RESTART MANAGER: Successfully shut down all applications in the service's session that held files in use.
    MSI (c) (84:94) [07:48:11:110]: RESTART MANAGER: Successfully shut down all applications that held files in use.
    MSI (s) (34:6C) [07:48:11:641]: Note: 1: 2727 2:  
    MSI (s) (34:6C) [07:48:11:641]: Doing action: InstallInitialize
    Action ended 07:48:11: InstallValidate. Return value 1.
    
    

    Any ideas?

    0 comments No comments

  3. Limitless Technology 44,751 Reputation points
    2023-04-28T14:29:52.5133333+00:00

    Hello there,

    Use Start-Process to installs the msi package from PowerShell using msiexec with the /i and/qn parameters. You can optionally test using the -wait parameter of Start-Process in case it helps in your particular case. There is also a /norestart parameter to use with msiexec.

    PowerShell

    $pkg = "D:\a\test\ultimate\WindowsApplicationDriver_1.2.1.msi";

    Start-Process msiexec "/i $pkg /qn";

    ##Start-Process msiexec "/i $pkg /qn" -Wait;

    ##Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  4. Christoph_H 20 Reputation points
    2023-05-02T09:30:51.2933333+00:00

    I'll explain the script:

    • First it will be checked, if a new version of our application was created/built
    • ( because of the problem i've told, i inserted some registry-checks to know if a server restart is required )
    • if a new version is available, the ZIP of the new version will extracted und the MSI-file inside will be installed with msiexec as shown before

    I now tried the following steps:

    • added the transcript-option in powershell
    • start the handle.exe right before the msiexec is executed
    • added the /norestart-parameter to the msiexec

    But nothing of them helped.
    (I also tried the "/qn" option, but this is not usable for us).

    Here is the transcript:

    **********************
    nStart der Windows PowerShell-Aufzeichnung
    Startzeit: 20230430113636
    Benutzername: MYDOMAIN\administrator
    RunAs-Benutzer: MYDOMAIN\administrator
    Konfigurationsname: 
    Computer: APPSRV1 (Microsoft Windows NT 10.0.17763.0)
    Hostanwendung: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\LC.Scripts\qstest\InstallMyApplication.ps1 C:\LC.Scripts\qstest\InstallMyApplication.config.xml
    Prozess-ID: 8652
    PSVersion: 5.1.17763.3770
    PSEdition: Desktop
    PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.3770
    BuildVersion: 10.0.17763.3770
    CLRVersion: 4.0.30319.42000
    WSManStackVersion: 3.0
    PSRemotingProtocolVersion: 2.3
    SerializationVersion: 1.1.0.1
    **********************
    Die Aufzeichnung wurde gestartet. Die Ausgabedatei ist "c:\install\MyApplication\InstallMyApplication.transcript.txt".
    [?] Check if a reboot is pending for this machine...
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft RebootInProgress ist im Pfad HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing nicht vorhanden.."
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft PackagesPending ist im Pfad HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing nicht vorhanden.."
    HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager > PendingFileRenameOperations    ... will be ignored
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft PendingFileRenameOperations2 ist im Pfad HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager nicht vorhanden.."
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft DVDRebootSignal ist im Pfad HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce nicht vorhanden.."
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft JoinDomain ist im Pfad HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon nicht vorhanden.."
    PS>TerminatingError(Get-ItemProperty): "Der ausgeführte Befehl wurde beendet, da die Einstellungsvariable "ErrorActionPreference" oder ein allgemeiner Parameter auf "Stop" festgelegt ist: Die Eigenschaft AvoidSpnSet ist im Pfad HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon nicht vorhanden.."
    False
    [?] Detect installed MyApplication version...
    [i] MyApplication version 5.4.9.0 detected.
    
    [i] Already tested versions:
    --- 5.4.10.0
    
    
    [+] MyApplication version 5.4.10.0 selected.
    
    [+] Installing MyApplication 5.4.10.0 - please wait...
    
    7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04
    
    Scanning the drive for archives:
    1 file, 557262673 bytes (532 MiB)
    
    Extracting archive: \\Fileserver\Published\Versions\MyApplication5.4.10.0.zip
    --
    Path = \\Fileserver\Published\Versions\MyApplication5.4.10.0.zip
    Type = zip
    Physical Size = 557262673
    
    Everything is Ok
    
    Files: 2
    Size:       583786977
    Compressed: 557262673
    
    
        Verzeichnis: C:\inetpub\wwwroot\MyRootFolder\Company
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----       30.04.2023     11:37              0 AutoInstall.txt
    [+] Run handle.exe for debugging...
    [+] Start-Process msiexec for WiX...
    
    

    And the output of handle.exe:

    
    Nthandle v5.0 - Handle viewer
    Copyright (C) 1997-2022 Mark Russinovich
    Sysinternals - www.sysinternals.com
    
       40: File  (RW-)   C:\Windows\System32
       C4: File  (R-D)   C:\Windows\System32\WindowsPowerShell\v1.0\de-DE\powershell.exe.mui
       CC: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation.Resources\v4.0_3.0.0.0_de_31bf3856ad364e35\System.Management.Automation.Resources.dll
      178: Section       \BaseNamedObjects\__ComCatalogCache__
      17C: File  (R--)   C:\Windows\Registration\R00000000000c.clb
      210: Section       \...\Cor_SxSPublic_IPCBlock
      214: Section       \BaseNamedObjects\Cor_Private_IPCBlock_v4_8652
      228: Section       \Sessions\7\BaseNamedObjects\windows_shell_global_counters
      244: Section       \BaseNamedObjects\windows_shell_global_counters
      24C: Section       \BaseNamedObjects\C:*ProgramData*Microsoft*Windows*Caches*cversions.2.ro
      250: Section       \BaseNamedObjects\C:*ProgramData*Microsoft*Windows*Caches*{6AF0698E-D558-4F6E-9B3C-3716689AF493}.2.ver0x0000000000000008.db
      254: Section       \BaseNamedObjects\C:*ProgramData*Microsoft*Windows*Caches*cversions.2.ro
      258: Section       \BaseNamedObjects\C:*ProgramData*Microsoft*Windows*Caches*{DDF571F2-BE98-426D-8288-1A9A39C3FDA2}.2.ver0x0000000000000005.db
      25C: File  (R-D)   C:\Windows\System32\de-DE\propsys.dll.mui
      448: File  (R--)   C:\Windows\assembly\pubpol95.dat
      470: Section       \BaseNamedObjects\__ComCatalogCache__
      484: Section       \RPC Control\DSEC21CC
      528: File  (R-D)   C:\Windows\System32\de-DE\winnlsres.dll.mui
      710: File  (R-D)   C:\Windows\System32\de-DE\crypt32.dll.mui
      760: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.PowerShell.ConsoleHost.Resources\v4.0_3.0.0.0_de_31bf3856ad364e35\Microsoft.PowerShell.ConsoleHost.Resources.dll
      770: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_de_b77a5c561934e089\mscorlib.resources.dll
      928: Section       \Sessions\7\BaseNamedObjects\UrlZonesSM_administrator
      940: Section       \BaseNamedObjects\NLS_CodePage_1252_3_2_0_0
      A48: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management.Resources\v4.0_3.0.0.0_de_31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.Resources.dll
      A4C: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_64\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll
      A5C: Section       \BaseNamedObjects\NLS_CodePage_850_3_2_0_0
      A74: File  (R--)   C:\install\MyApplication\InstallMyApplication.transcript.txt
      B7C: File  (R-D)   C:\inetpub\wwwroot\WebServicesRoot\ServerConfigurator\bin\MyApplication.exe
      BB4: File  (R-D)   C:\Windows\System32\de-DE\KernelBase.dll.mui
      BF4: File  (R--)   C:\install\MyApplication\InstallMyApplication.handle.txt
      C24: File  (R-D)   C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.IIS.PowerShell.Provider.Resources\v4.0_10.0.0.0_de_31bf3856ad364e35\Microsoft.IIS.PowerShell.Provider.resources.dll
      C50: File  (RWD)   C:\Windows\System32\inetsrv\Config\Schema
      C58: File  (RWD)   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
      C5C: File  (RWD)   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
      C60: File  (RWD)   C:\Windows\System32\inetsrv\Config
      C64: File  (RWD)   C:\Windows\System32\inetsrv\Config
    
    

    The only file that could cause an "error" (in my opinion) would be "c:\inetpub\wwwroot\WebServicesRoot\ServerConfigurator\bin\MyApplication.exe". But it doesn't explain why the powershell script will be terminated.

    Interestingly, the same script works on our test servers (also Windows Server 2019) but not on the application server (but it has worked for a while). On all machines we install the application with the domain-administrator, we can therefore rule out that the user has something to do with it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.