Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:12:04+00:00 2026-05-24T20:12:04+00:00

I’m scripting the installation and configuration procedure for my company’s desktop application. We send

  • 0

I’m scripting the installation and configuration procedure for my company’s desktop application. We send out a kiosk and can’t put everything in the installer… moving right along! I’m using Start-Process to wait for msiexec to complete.

function Run-Installer
{
    param
    (
        [string] $msi = $(throw "Required parameter: 'msi'"),
    )

    if(-not(Test-Path $msi -Type Leaf))
    {
        throw "The installer could not be found: '$msi'"
    }

    $name = (Get-Item $msi).BaseName

    Write-Host "Installing $name"

    $p = 
    @(
        "/I `"$msi`"",                    # Install this MSI
        "/QN",                            # Quietly, without a UI
        "/L*V `"$ENV:TEMP\$name.log`""    # Verbose output to this log
    )

    Start-Process -FilePath "msiexec" -ArgumentList $p -Wait
}

Where I want to get fancy is with the log output from msiexec. I want to stream the contents of the log to the console while the installer is running. I’m guessing there are multiple parts to the solution

  1. Running the installer in a background, waitable manner
  2. Tailing the log file until some condition is met (installer job completes)
  3. Optional: Filtering the output or writing to debug/verbose for fun
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:12:04+00:00Added an answer on May 24, 2026 at 8:12 pm
    function Start-FileTail {
        param($path)
        # Get unique source ID
        $sourceID = "FileTailLine-" + [guid]::NewGuid()
    
        $job = Start-Job -ArgumentList $path, $sourceID {
            param($path,$sid)
    
            Register-EngineEvent -SourceIdentifier $sid -Forward
    
            do{}until(Test-Path $path)
    
            $fs = New-Object IO.FileStream ($path, [IO.FileMode]::Open, 
                    [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite)
            $sr = New-Object IO.StreamReader ($fs)
            $lines = @()
    
            while(1) {
                $line = $sr.ReadLine()
                $lines += $line
                # Send after every 100 reads
                if($lines.Count -gt 100) {
                    # Join lines into 1 string
                    $text = @($lines| where {$_} ) -join "`n"
                    # Only send if text was found
                    if($text){New-Event -SourceIdentifier $sid -MessageData $text}
                    $lines = @()
                }
            }
        }
    
        $event = Register-EngineEvent -SourceIdentifier $sourceID -Action {
            Write-Host $event.MessageData
        }
        New-Object Object|
            Add-Member -Name Job -Type NoteProperty -Value $job -PassThru|
            Add-Member -Name SourceIdentifier -Type NoteProperty -Value $sourceID -PassThru
    }
    
    function Stop-FileTail {
        param($TailInfo)
        Remove-Job $TailInfo.Job -Force
        Unregister-Event -SourceIdentifier $tail.SourceIdentifier
    }
    

    You can remove the job, and unregister the event once the install is done.

    Change Write-Host to Write-Verbose for -Verbose support

    EDIT: I tested my answer while installing an application, and found that it was pretty slow when reading the log file. I updated the Get-Content call to use -ReadCount 100 to send the data as arrays of lines. The Write-Host line was updated to handle the arrays.

    I also found that using the -Wait switch on Start-Process caused all of the log output to be written after the install was finished. This can be fixed by using:

    $msi = Start-Process -FilePath "msiexec" -ArgumentList $p -PassThru
    do{}until($msi.HasExited)
    

    EDIT 2: Hmm, I don’t get all of the log file when I use -Wait and -ReadCount together. I put the reading of the log file back to how I originally had it. I’m not sure what to do about the speed yet.

    EDIT 3: I’ve updated the code to use a StreamReader instead of Get-Content, and put the code into functions. You would then call it like:

    $path = "$ENV:TEMP\$name.log"
    if(Test-Path $path){Remove-Item $path}
    
    $msi = Start-Process -FilePath "msiexec" -ArgumentList $p -PassThru
    $tail = Start-FileTail $p
    do{}until($msi.HasExited)
    sleep 1 # Allow time to finish reading log.
    Stop-FileTail $tail
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.