Get-childitem filter down

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 5 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
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Get-childitem filter down

Post by MarvelManiac »

So we have 850 plus folders out on a network share that has user data so for example the full path would be

\\server1\data\username1
\\server1\data\username2
\\server1\data\username3
\\server1\data\username4
\\server1\data\username5
etc...

Insdide each username folder are 4 folders and some text files, like this
share.png
share.png (20.57 KiB) Viewed 1783 times
What I want to do is just search the Logs folder under each username for a specific .log file to select-string
To make this even more daunting, there are about 20-30 .log files inside the log folder

Here is my starting point
Get-childitem \\server1\data -Recurse -Include *.log | Select-String 'Network Limit', 'Run Interval'

Just trying to add some powershellfu and search just the Logs directory
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get-childitem filter down

Post by jvierra »

Try it like this:

Code: Select all

Get-ChildItem \\server1\data\*\logs  -Directory | 
	ForEach-Object{ 
		Get-ChildItem $_ 
	} |
	Select-String  'Network Limit', 'Run Interval'
User avatar
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Re: Get-childitem filter down

Post by MarvelManiac »

Gasp! I can't believe it was so simple
puny brain
this will give me a great way to learn regex & replace since my string now looks like this

\\server\Data\user\Logs\Application_Run_2017-05-17.log:1317:2017-05-17_13-45-53 : Network Limit = 1

There will literally be thousands of these files and I just want to export it to a table\csv\excel and have it look like this

Code: Select all

Server         User          NetworkLimit
servername     username      Very last digit
Cheers!
This topic is 6 years and 5 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