Uninstall Office 2013 and install Office 365 Powershell


I need the following powershell script and i cant figure out how to make this.

------------ pseudo powershell code ----------

Tjeck for office 2013 installation.

IF Office 2013 is installed, remove Office 2013 and Install/upgrade to Office 366

ELSE run Office 365 Quickrepair with finish dialog “Repair done”

End of script

Can someone help me with this?

Best regards

Brian Petersen

IMHO you should yourself :slight_smile: This is not cookbook forum :slight_smile:

[ul]To check if app is installed I would use Get-WmiObject -Class Win32_Product[/ul]
[ul]To uninstall app I would get MSI GUID from first command and run [/b][/ul]
[ul]To install app I would use quiet installation method of app [/b][/ul]

Have a look here and here.

Hi, yes i know and i should have wrote, that i am indeed trying.
I am working on a powershell script now, but have run into the first problem.

I want to run a windows troubleshooter file (.diagcab) SILENT, from a powershell script. This file uninstalles ALL office instances on a client.
I manage to read that you have to make a answerfile to make it silent but im stuck here. :o/

Could you give an example from your script on how you are running the troubleshooting pack?

This is stated in the help file for “Get-TroubleshootingPack”:

Example 4: Generate an answer file

Get-TroubleshootingPack -Path "C:\Windows\Diagnostics\System\Audio" -AnswerFile "AudioAnswerFile.xml"

This command uses the Get-TroubleshootingPack cmdlet to generate an answer file. The Areo troubleshooting pack provides
a series of questions for the user to describe the troubleshooting situation and saves that information in the specified XML file.

This is stated in the help file for “Invoke-TroubleshootingPack”:

Example 3: Run a troubleshooting pack in unattended mode

$Audio = Get-TroubleshootingPack -Path "C:\Windows\Diagnostics\System\Audio"
Invoke-TroubleshootingPack -Pack $Audio -AnswerFile "AudioAnswerFile.xml" -Unattended

This example runs the Audio pack in unattended mode with a specified answer file.

The first command uses the Get-TroubleshootingPack cmdlet to get a DiagPack object and stores it in the $Audio variable.

The second command invokes the troubleshooting pack stored in $Audio in unattended mode. The command specifies an answer
file, previously created by using the Get-TroubleshootingPack cmdlet.

I can’t test this on your specific diagcab but you could try to run the first example I showed you and then the second one, with your specific paths of course.



I managed to do it with your help.