PowerShell: Make an Installation Process Silent

363 Views Asked by At

I have a script that calls an application from Microsoft's Company Portal and automatically installs it. This launches Company Portal, potentially disrupting end user workflow. Is there any way to make this process run in the background? I tried to add an Argument List, but the process still launches Company portal. Any ideas? Thanks.

$OutputFile = "$env:WINDIR\TEMP\PythoncpInstall.log"
$Process = "companyportal:ApplicationId=e60a5520-dc39-4156-9223-825264cd5145"
$ProcessArgs = " /s -Wait -NoNewWindow"

##########ERROR LOGGING#####
Function Set-WriteToLog ($Write1)
{
    Write-Host "$(Get-Date -format yyyy-MM-dd-hh-mm-ss)`t-`t$Write1"
}
#########START OF SCRIPT BODY#############
Start-Transcript -Path $OutputFile
start-process $Process -ArgumentList $ProcessArgs
sleep 10
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("^{i}")

Stop-Transcript
1

There are 1 best solutions below

1
Start-Automating On

Without knowing more about the application and its installer, I'm not sure how if what I will suggest will work. Please share this information when you can.

What might help you is using Start-Process with -RedirectStandardInput and -WindowStyle.

-RedirectStandardInput will allow you to provide a text file that will be passed to standard input. This might let you provide input, depending on how the installer is implemented.

-WindowStyle would allow you to launch the process minimized or hidden.

Unfortunately, the way your code is currently written relies on SendKeys, which would in turn rely on the window being visible and focused.

Please let me know what installer you're using (if it's external), and I might be able to provide more help.