OfficeDev / Office-IT-Pro-Deployment-Scripts

A collection of useful PowerShell scripts to make deploying Office 2016 and Office 365 ProPlus easier for IT Pros and administrators. If you have any feature requests or ideas for future scripts please add the idea to the issues list in this repository
http://officedev.github.io/Office-IT-Pro-Deployment-Scripts
MIT License
887 stars 840 forks source link

Remove-PreviousOfficeInstalls error "You cannot call a method on a null-valued expression" When no Office Installed #261

Closed wongcarter closed 7 years ago

wongcarter commented 7 years ago

This error occurs when you set $ProductsToRemove to "MainOfficeProduct" and Office is not installed at all.

Error occurs at line 1363, because Get-OfficeVersion returns a null value, and GetProductName is not set up to handle a null value from Get-OfficeVersion.

AStigall commented 7 years ago

We have added error handling if no product is found.