Matching Items

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

Matching Items

Post by localpct »

I have a form that I use to match against standard applications. Currently, there are 400+ files I do not want to view
The files are names of standard applications ( flash, shockwave, Java, Office) that are in a directory

example
sendout.png
sendout.png (45.97 KiB) Viewed 3452 times
I have the form working, what I need to do to make this application pull from an external source (txt or csv ) as all 400 items are hard coded currently as you can see.

The point of the application would be, if we install Apple Quicktime on everyones computer, that will pull into the application, which I don't want to do. I also, wouldn't want to redistribute the application due to one line of code. I can just update the external source to not match the new line

Thanks!
Attachments
Get-Apps_SendOut.psf
(168.97 KiB) Downloaded 132 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Matching Items

Post by jvierra »

No. I cannot tell that they are hardcoded.
You can load a text or CSV file with either "Get-Content" or "Import-Csv". See the help for examples of how to use these.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Matching Items

Post by localpct »

If you open the psf, you'll see them hard coded into the application

Just trying to get all of them on a txt or CSV file. I've tried both get-content and import-CSV with
-notlike
-ne
-notmatch

But I can only get it to display correctly, using not-match hard coded in the application
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Matching Items

Post by jvierra »

What are you trying to match?

$lines = Get-Content <filename> | Where {$_ -notmatch 'somevalue'}
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Matching Items

Post by localpct »

I believe looking at the attached form will help

But I'm trying to -notmatch against textfiles.

Please let me know if you can, or cannot view the picture of my windows explorer and the .psf file

Thanks!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Matching Items

Post by jvierra »

Sorry but the picture does 't tell me what you are trying to ask. You need to try and ask a clear question. The picture just shows a list of names of something.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Matching Items

Post by localpct »

Have you downloaded the form?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Matching Items

Post by jvierra »

Yes. It still doesn't help much. YOU have a hardcoded list and you want to find everything tha tis not in it.

This is my best guess.

$list1 |Where{ $_ -notin $list2}
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Matching Items

Post by localpct »

You're absolutely right, I do have it hard coded and I want that giant list of -notmatch pulled from a txt or CSV file on a server, instead of within the application.

I've tried -notin to no avail

I just want to return from the PC what's not in the list

As stated, running it as it is, perfect.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Matching Items

Post by jvierra »

Sorry but I still cannot understand what your question is. What doesn't work? What are you trying to do?

You have to find a way to ask the question so that it is clear what you are trying to do. What are you trying to return from what PC?

I can only see that you are listing a bunch of files and trying to match them to a bunch of strings.

-match uses RegEx. It will have issues with strings that have meta characters.

If you want to exclude files by name use "-Exclude" with an array of names and wildcards and those files will be skipped.

You can also use Where{ $_.Name -notin $list }
This topic is 6 years and 7 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