Using PowerShell to detect and remove certain type of software?

Ask your Windows 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.
User avatar
ITEngineer
Posts: 138
Joined: Wed Oct 12, 2011 10:52 am

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

Post by ITEngineer » Thu Dec 13, 2018 4:44 am

jvierra wrote:
Wed Dec 12, 2018 11: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 */

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Dec 13, 2018 12:06 pm

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>

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Dec 13, 2018 12:41 pm

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 19 times

Locked