0

I am attempting to update a script we currently have at my position. My want is to be able to pull up a list of installed software on a PC however, I would like to exclude things such as "Windows Redistributables" & other OS-standard programs. I am not sure if I would have to make a text file with the full names of the programs verbatim and have the command run and exclude those names or if their is a simpler way to do that. Which is why I am here. The current command we use is listed below.

Get-InstalledSoftware -Computername $env:computername | Select-Object Name,Version,ComputerName |Format-table

SammyD007
  • 5
  • 4
  • Assuming `Get-InstalledSoftware` is a custom function built by someone in your company, I would recommend modifying the code to add an extra `-Exclude` parameter for *built-in* functionality. Other than that, you can use a filter cmdlet such as `Where-Object` to filter out the unwanted data. – Abraham Zinala Aug 22 '22 at 14:20

1 Answers1

1

One Possibility filter out anything with Microsoft in the Name.

Get-InstalledSoftware -Computername $env:computername | 
   Where-Object Name -NotLike "*Microsoft*"           |
   Select-Object Name,Version,ComputerName            |
   Format-table
RetiredGeek
  • 2,980
  • 1
  • 7
  • 21
  • So, after running this it does work. So, firstly, thank you very much; Secondly, would it be at all possible to put this into a .txt and have it run through the txt file to make the code a little cleaner (as in run the ```Where-Object Name -NotLike``` list as a single command through a .txt file or something akin to that? – SammyD007 Aug 22 '22 at 21:02
  • @SammyD007, the code is written like that for ease of readability. It will run as written no need to have it on a single line. If you want to save it paste the code into Notepad and then save it as a .ps1 file and you can run it from the PowerShell command prompt. If the answer meets your needs please mark it as accepted by clicking the check mark. – RetiredGeek Aug 23 '22 at 00:04