Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
jvierra wrote: ↑Tue Dec 11, 2018 8:54 pm
As I noted, the code as posted cannot work. It does not do anything you expect from what I see. It attempts to uninstall everything.
You try to uninstall everything that matches and doesn't math O365. That includes all software.
The following logic includes all things found:
if ($uninstall.DisplayName -like "*365*") {
} ElseIf ($uninstall.DisplayName -notlike '*365*') {
}
The code you have was originally designed to install one office product but seems to have been changed badly.
Hi Mr. Vierra,
yes, the goal of the script is to uninstall the Software that is matching the $AppDisplayName variable.
in this example, I need to uninstall Microsoft office.
Here is a rethink of what you are doing. It can help you to discover your issue. It is tested. I am posting it to help you get an idea of how you have to approach a problem like this. It will not remove anything until you change the "$ShouldProcess" variable.
jvierra wrote: ↑Wed Dec 12, 2018 5:54 pm
Here is a rethink of what you are doing. It can help you to discover your issue. It is tested. I am posting it to help you get an idea of how you have to approach a problem like this. It will not remove anything until you change the "$ShouldProcess" variable.
Mr. Vierra,
Thanks for the help,
however, the script run with the error below:
The "=" operator is missing after a named argument.
At line:7 char:29
Missing function body in function declaration.
At line:17 char:2
Missing function body in function declaration.
At line:23 char:2
The "=" operator is missing after a named argument.
At C:\Users\Admin\Desktop\Test-RemoveOffice (1).ps1:7 char:30
+ [Parameter(Mandatory) <<<< ]
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEqualsInNamedArgument
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.