How to create a PowerShell Script to detect all versions of Microsoft Project present on machine and Uninstall all except the latest version?

Hello Friends,

I am assigned this project to Clean machines having multiple versions of Project installed with single and latest version out of them. According to reports generated their are 5 versions of Microsoft Project present in our organization namely

Microsoft Project 2003

Microsoft Project 2007

Microsoft Project 2010

Microsoft Project 2013

Microsoft Project 2016

These versions further are classified into “Project Standard” and"Project Professional" and further into 32bit/64bit installation

The task is to detect which out of these versions are installed on machine then Uninstall all except the latest one out of them. I have tried to put some logic like below but it won’t work because scenarios are way more to consider then my mind can take. I really appreciate if someone can guide me through the solution.

if( Present Project2007 and Project2010… and ProjectN)

{

Uninstall(All except ProjectN)

}

if( Present Project2007 and Project2010… and Project(N - 1))

{

Uninstall(All except Project(N - 1))

} and so on

but if a machine has Project2007 and Project 2013 installed then this logic will fail

Here is my incomplete code appreciate if some one can help!

$Project2003STD = Test-Path “C:\Program Files\Office 2003\OFFICE11\WINPROJ.EXE”

    $Project2003x86STD = Test-Path "C:\Program Files (x86)\Office 2003\OFFICE11\WINPROJ.EXE"



    $Project2003Pro = Test-Path "C:\Program Files\Microsoft Office\OFFICE11\WINPROJ.EXE"

    $Project2003x86Pro = Test-Path "C:\Program Files (x86)\Microsoft Office\OFFICE11\WINPROJ.EXE"



    $Project2007STD = Test-Path "C:\Program Files\Office 2007\Office12\WINPROJ.EXE"

    $Project2007x86STD = Test-Path "C:\Program Files (x86)\Office 2007\Office12\WINPROJ.EXE"



    $Project2007Pro = Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\PRJPRO\PrjProWW.XML"

    $Project2007x86Pro = Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\PRJPRO\PrjProWW.XML"



    $Project2010STD = Test-Path "C:\Program Files\Office 2010\Office14\WINPROJ.EXE"

    $Project2010x86STD = Test-Path "C:\Program Files (x86)\Office 2010\Office14\WINPROJ.EXE"



    $Project2010STD64bit = Test-Path "C:\Program Files\Microsoft Office\Office14\WINPROJ.EXE"



    $Project2010Pro = Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\PRJPRO\PrjProWW.XML"

    $Project2010x86Pro = Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\PRJPRO\PrjProWW.XML"



    $Project2013STD = Test-Path "C:\Program Files\Microsoft Office\Office15\WINPROJ.EXE"

    $Project2013STDx86 = Test-Path "C:\Program Files (x86)\Microsoft Office\Office15\WINPROJ.EXE"



    $ProJect2016Pro = Test-Path "C:\Program Files\Microsoft Office\root\Office16\WINPROJ.EXE"

    $Project2016Prox86 = Test-Path "C:\Program Files (x86)\Microsoft Office\root\Office16\WINPROJ.EXE"



    

    if($is64bit)

   { 

   

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro) -and ($Project2010STD -or $Project2010x86STD)  -and ($Project2010STD64bit) -and ($Project2010Pro -or $Project2010x86Pro) -and ($Project2013STDx86 -or $Project2013STD) -and ($ProJect2016Pro -or $ProJect2016Prox86))

    {

    

    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

    #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }



    #Project2007x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }

    #Project2010STD64bit/#Project2010STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2010Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2010x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2013STDx86

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE15\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE15\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE15\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2013STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    

    

    }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro) -and ($Project2010STD -or $Project2010x86STD)  -and ($Project2010STD64bit) -and ($Project2010Pro -or $Project2010x86Pro) -and ($Project2013STDx86 -or $Project2013STD))

    {

    #Project2010x86Pro

   		

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

    #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }



    #Project2007x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }

    #Project2010STD64bit/#Project2010STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2010Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2010x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro) -and ($Project2010STD -or $Project2010x86STD)  -and ($Project2010STD64bit) -and ($Project2010Pro -or $Project2010x86Pro))

    {

    





    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

    #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }



    #Project2007x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }

    #Project2010STD64bit/#Project2010STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



   

    }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro) -and ($Project2010STD -or $Project2010x86STD)  -and ($Project2010STD64bit))

    {

    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

    #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }



    #Project2007x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }

    #Project2010STD64bit/#Project2010STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010x86Pro

   		

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro) -and ($Project2010x86STD))

    {

    

    #Project2010x86Pro

   		

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2010Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

    #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007Pro

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }



    #Project2007x86Pro

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjPro /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true 

    }

   }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD) -and ($Project2007Pro -or $Project2007x86Pro))

    {

    

    #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

     #Project2007STD

    if (Test-Path "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }



    #Project2007x86STD

    if (Test-Path "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\SETUP.EXE")

    {

    Copy-Item -Recurse "$dirFiles\UninstallProject.xml" "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller"

    execute-process "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\setup.exe" -Parameters '/uninstall PrjStd /dll OSETUP.DLL /config UninstallProject.xml' -ContinueOnError $true  

    }

   }

    if(($Project2003STD -or $Project2003x86STD) -and ($Project2003Pro -or $Project2003x86Pro) -and ($Project2007STD -or $Project2007x86STD))

    {

   #Project2003STD

    if ($Project2003STD -or $Project2003x86STD)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }



    #Project2003Pro

    if ($Project2003Pro -or $Project2003x86Pro)

    {

    Execute-Msi -Action 'Uninstall' -Path '{903A0409-6000-11D3-8CFE-0150048383C9}' -Parameters "/qn"

    }

   }




    }