Where -notlike

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 7 years and 5 days 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
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Where -notlike

Post by localpct »

I'm trying to write an application that will filter out standard applications and vendor logs
Here lies my problem
We have multiple versions of Adobe Air installed ie
Adobe Air 13.0.0.111.LOG
Adobe Air 14.0.0.178.LOG
Adobe AIR 18.0.0.180.LOG
etc...

How can I get it so I can just write

*Adobe Air*

And it removes all txt files that end in Adobe Air, or Adobe Flash, Java, Office, etc...

So I put in a PC number into my gui, and it list what applications the person actually has that are non standard
Chrome
Project
Visual Studio
PowerShell Studio

etc...

I prefer to do this in a csv file if possible so I can update these applications on the fly
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Where -notlike

Post by jvierra »

Sorry but your question is too vague. Can you post the code you are trying to us
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Where -notlike

Post by localpct »

So just imagine you have a enterprise client. With 100 or so pieces of software that is on every machine. When I want to populate what's on the current PC, I only want to see a few applications that are non standard
SiteSurveyApps.psf
(114.25 KiB) Downloaded 142 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Where -notlike

Post by jvierra »

Get-WmiObject Win32_Product -Filter "Name='%adobe%'"
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Where -notlike

Post by localpct »

That's not the answer since I'm going to filter out 100 or so applications
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Where -notlike

Post by jvierra »

That will filter 100s of applications.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Where -notlike

Post by localpct »

wouldn't I have to have a filter for each app I want to exclude?

Is there no way for it to read from a CSV file?
I don't want to hard code it into the application seeing our images change once every 6 months and if there is something I missed, it'd be much easier than redistributing the application to 110 employees
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Where -notlike

Post by jvierra »

You asked about a filter. "%Adobe AIr%" is a filter which will return any product matching that filter.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Where -notlike

Post by localpct »

If you re-read my original post. I need it to filter out 100 or so applications from a CSV file
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Where -notlike

Post by jvierra »

Your post said:

How can I get it so I can just write

*Adobe Air*

To filter out many then use "notin" on the file

Get-WmiObject Win32_Product |where{$_.Name -notin (Get-Content filename)}
This topic is 7 years and 5 days 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