Using PowerShell to detect and remove certain type of software?

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 3 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.
Locked
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Re: Using PowerShell to detect and remove certain type of software?

Post by ITEngineer »

jvierra wrote: Wed Dec 12, 2018 10:03 pm PowerShell 2 is no longer supported by Microsoft. It is considered a security problem. You need to upgrade.

PS does not support most of the extensions to PS at V3 and later. Just add the "= $true" to the "[Parameter(" statement

[Parameter(Mandatory=$true)]
Mr. Vierra,

Thanks for the update, I can see the script is now working:

Image

Do I just set the command switch below to make it happens?

$WhatIfPreference = $true
$global:ShouldProcess = $true
/* IT Engineer */
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using PowerShell to detect and remove certain type of software?

Post by jvierra »

To further modify the design to obtain the desired behaviors we can use PwoerShell's built-in capability of setting and managing the preferences dynamically.

Here is how that is accomplished in code.

<file to be posted>
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using PowerShell to detect and remove certain type of software?

Post by jvierra »

I have modified the example to produce extra messages that make what is happening easier to understand - I think.
Attachments
Remove-Office.ps1
(2.58 KiB) Downloaded 114 times
This topic is 5 years and 3 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.
Locked