powershell script to create a report of all folders-subfolders a files that matches with a specific criteria in Windows 2012

Hi Experts,

My manager asked me to generate a report  of all folders/subfolder and files that matches with a specific criteria, for example all folders/sub-folders, files where the name of file and the body and or subject is "CONTRACT" then export all info ont a CSV file

I actually have a WIndows server 2012 cluster with multiple nodes, and this cluster is the repository of data of all users'network map drive.

I should be able to find any docs based on a specific criteria such as file/folder name, subject and body. From windows explorer and can perform a search for folders/sub-folders and files based on specific criteria, but i would like to be able to perform this from powershell and generate a report that i can send to all managers

Any ideas?
Jerry SeinfieldAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rob StoneCommented:
You can try this:

$Criteria = $null
$Path = $null
$Logpath = $null
$Logfile = $null
$date = $null
$Search = $null

$Criteria = Read-Host "Enter the search string here"
$Path = Read-Host "Enter the Path to run the query against"
$Logpath = "C:\Users\Robsto.ent"
$Logfile = "Report_"$Criteria
$Date = Get-Date -Format yyyyMMdd_

$Search = gci -Path $Path -Filter $Criteria -Recurse |Select-Object Fullname, Name, Extension
$Search |Export-CSV -Path "$Date+$LogFile.csv"

Open in new window


Note, I've put the '-Resurse' switch in which can take ages on a large file structure.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.