Help with Start-Process arguments for Office2019 install


I wrote the following code, but when I run the script, I get a prompt from setup.exe that states the configuration file could not be found. I currently have a folder where I have a batch file that calls powershell scripts while bypassing the execution policy. The folder structure is as follows:

Updates (directory)
-office2019 (directory)
–Office (directory)

Here is the code from office2019.ps1:

$officePath = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\"
$currentVersion = Get-ItemPropertyValue -Path $officePath -Name ClientVersionToReport
$targetVersion = $targetVersion = (Get-ChildItem -Path $PSScriptRoot\Office\Data -Directory).Name

If (Test-Path $officePath) {
    Write-Host "Office 2019 was found."
    Write-Host "Current Version: $currentVersion"
    Write-Host "Target Version: $targetVersion"
    If ($currentVersion -lt $targetVersion) {
        Write-Host "Office 2019 installation will be updated to $targetVersion"
        Start-Process -Wait -FilePath $PSScriptRoot\setup.exe -ArgumentList "/configure $PSScriptRoot\SYS-2019-Configuration.xml" -PassThru
        Write-Host "Office 2019 has been updated to version $targetVersion"
Else {
    Write-Host "Installation not found.  Skipping."

The exact error that I receive is:

If anyone can help me figure out what I am doing wrong I would greatly appreciate it!


Have you tried to set the directory of the script to the working directory with Push-Location or Set-Location and run the setup without the path in the command line?

Push-Location -Path $PSScriptRoot
Start-Process -FilePath 'setup.exe' -ArgumentList '/configure SYS-2019-Configuration.xml' -Wait -PassThru
1 Like

@Olaf - That worked! Thank you so much for the tip!