Optional Show-InstallationProgress?

Hello,

I have an improvement I’d like to make to our PSADT deployments so they act more silently for the user when doing the installs.
Let me explain…
Using Azure Data Studio as my example, In the PRE-INSTALLATION section of our deployments, I have:

Show-InstallationWelcome -CloseApps 'azuredatastudio=Azure Data Studio' -AllowDeferCloseApps -DeferTimes 3 -CheckDiskSpace -PersistPrompt -TopMost $true
Show-InstallationProgress

This is fine if the azuredatastudio process is running when the install lands as it prompts the user to close the app before notifying them the installation is in progress via the use of Show-InstallationProgress, but, if the azuredatastudio process is not running when the install lands I would prefer that the install does not display Show-InstallationProgress - Why bother telling the user we are updating an app they are not currently using?

I’m guessing that it would require the Show-InstallationWelcome function to be modified so it has an output (e.g. ‘appsrunning’) which could be tested before deciding if the Show-InstallationProgress should be displayed?

I think I’m answering my own question here, without a modification of the function mentioned above - do I need to check for the existence of the running process before the Show-InstallationWelcome command?, so that the code would look like:

if (Get-Process azuredatastudio -ErrorAction SilentlyContinue) {
    #Process is running
    Show-InstallationWelcome -CloseApps 'azuredatastudio=Azure Data Studio' -BlockExecution -MinimizeWindows $false -AllowDeferCloseApps -DeferTimes 3 -CheckDiskSpace -PersistPrompt -TopMost $true
    Show-InstallationProgress
} else {
    #Process is not running
    Show-InstallationWelcome -CloseApps 'azuredatastudio=Azure Data Studio' -BlockExecution -MinimizeWindows $false -AllowDeferCloseApps -DeferTimes 3 -CheckDiskSpace -PersistPrompt -TopMost $true
}
1 Like

Hi Adrian,

To me the scenario you describe and the code in the “else” statement is somewhat inconsistent. You say that you don’t want to bother the user if the process is not running but you use the Defer functionality so the user will get prompted 3 times regarding the update. I would remove the Deferal part to make it more “silent” in that scenario.

Yes good point I will probably do that. Thanks
N.B. I was just trying to show my thought process via the non-use of Show-InstallationProgress

P.S. I have the Apps to Close defined as a Variable so I can re-use for the Installation and Uninstallation sections - here is an example from my Adobe Acrobat Pro DC script containing each of the process names and Friendly names:

$AppstoClose = "iexplore=Internet Explorer,AcroRd32=Adobe Reader,acrobat=Adobe Acrobat,cidaemon,winword=Microsoft Word,excel=Microsoft Excel,outlook=Microsoft Outlook"

It’s not rocket science, but I have a block of code that will convert this process and friendly name string to just the list of process names into a $ProcessestoClose variable

# Convert the $AppstoClose string to just a list of processes to close
# Split the string by commas
$processArray = $AppstoClose.Split(',')

# Extract the process names
$ProcessestoClose = $processArray.ForEach{
        if ($_ -match "=") {
        $_.Split('=')[0]
    } else {
        $_
    }
}

This then allows me in each script to use the $ProcessestoClose variable in my ‘check if a process is running’ block, this way, I only have to maintain a single list of processes and friendly names that affect this install:

if (Get-Process $ProcessestoClose -ErrorAction SilentlyContinue) {
...
1 Like

Recently I was asked to install apps silently without GUI so users are not disturbed with a random popup of XYZ is installing.
This is how we achieved that, if it helps someone.
We defined the processes to terminate in the $variables at the top,

$process = 'msedge'
$fprocess = 'Microsoft Edge'
$process2 = 'chrome'
$fprocess2 = 'Google Chrome'
$processnames = @("$process","$process2","$process3")
$silent = $true
foreach($processname in $processnames) {
$activeprocess = Get-Process -Name $processname -ErrorAction SilentlyContinue
if($null -ne $activeProcess)
{
Write-Log -Message "Process(es) are found running, this will make it an interactive installation."
$silent = $false
Show-InstallationWelcome -CloseApps "$process=$fprocess,$process2=$fprocess2,$process3=$fprocess3" -DeferTimes 5 -AllowDeferCloseApps -ForceCloseAppsCountdown 1800
}
}

if($silent -eq $false)
{
Show-InstallationProgress "$appVendor $appname $appVersion Installation is in Progress."
}

You will just have to make sure to add

if($silent -eq $false)

everywhere you have GUI presence so the installation can be silent if the end user doesn’t have the apps open.

3 Likes