Trying to execute the following:
function Repair-Office-Apps {
$OfficeRepair = "/repair ProPlus /config \\server\path$\Custom\MS_Repair\SilentRepairConfig.xml"
$Office2013 = "\\server\packagepath$\MsOffice2013\setup.exe"
$Office2016 = "\\server\packagepath$\MsOffice2016\setup.exe"
# Detect Office Version and repair
$applist = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -like "*Microsoft Office Professional Plus 2010*" -or
$_.Name -like "*Microsoft Office Professional Plus 2013*" -or
$_.Name -like "*Microsoft Office Professional Plus 2016*"
}
if ($applist) {
foreach ($app in $applist) {
$AppName = $($app.name)
Write-Host "$AppName has been detected for repair"
if ($AppName -match "Microsoft Office Professional Plus 2010") {
Set-Location "C:\Temp\MS_remove"
Write-Host "Unable to repair Microsoft Office 2010. please manually repair or use the Office reinstall job"
} else {
if ($AppName -match "Microsoft Office Professional Plus 2013") {
Write-Host "Repairing Microsoft office 2013."
& $Office2013 -ArgumentList $OfficeRepair
} else {
Write-Host "Repairing Microsoft office 2016."
& $Office2016 -ArgumentList $OfficeRepair
}
}
}
} else {
Write-Host "No application(s) detected for uninstall"
}
}
. Repair-Office-Apps
The detection of the product works fine, as I use this for uninstalls elsewhere. The help window for the setup executable appears when you run the PowerShell Script, I am unsure on what I am doing wrong when passing the command line arguments. Ideally I would like to pass this command through as a job and query the job results but I thought it best trying to get the basic command built first.