Need help Creating a Powershell script

Greeting Experts,

I need help creating a script that can scan a list of File Shares (from .txt file) on Microsoft Active Directory Infostructure. The script needs to be able to look the name of files ( with difference file extensions)  and folders that contain keywords in the file name. Then put that into a .csv file with the name of the file, path location, date created, and person username who created it.   The purpose of this script it to quickly search for files file names that contain different keywords (i.e. 4-5 keywords) from a text file. Doing this in manual fashion takes too much time, and records can be missed. Where a script can be more efficient processes. Can somebody help me with this task?..
MikeSecurityAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

JesterTooCommented:
Could you please provide a step-by-step list of the exact process and does it absolutely have to be a Powershell script?  There may be other simple ways to accomplish what you want.
0
Jason CrawfordTransport NinjaCommented:
What is in the .txt file?  UNC paths or server names/IPs?  Where are you going to save the keywords?
0
Chris DentPowerShell DeveloperCommented:
The following example supports a very simple keyword list. Including things like file extensions will confuse it.
$keywords = (Get-Content yourList.txt) -join '|'
Get-ChildItem C:\Somewhere -Recurse |
    Where-Object BaseName -match $keywords |
    Select-Object Name, FullName, CreationDate, LastWriteTime,
        @{Name='Owner';Expression={ (Get-Acl $_.FullName).Owner }}

Open in new window

It won't be particularly fast for a large structure, and it only supports that list of 4 or 5 keywords. If you had 20 or more keywords the regular expression it generates ($keywords) would become quite unpleasant.
1
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

MikeSecurityAuthor Commented:
Thanks Chris for the script you posted. I tested the script with keywords ( i.e. names of files on my local drive) and used the direct path to my desktop (Win7) and did not output anything.... any ideas....
0
MikeSecurityAuthor Commented:
Does anybody have any suggestions to the following script post above....
0
Chris DentPowerShell DeveloperCommented:
Sorry, lost track.

I can't find any problems with it. This is my test set.
$keywords = ('powershell', 'powershell_ise') -join '|'

# $keywords = (Get-Content yourList.txt) -join '|'
Get-ChildItem C:\Windows -Recurse |
    Where-Object BaseName -match $keywords |
    Select-Object Name, FullName, CreationDate, LastWriteTime,
        @{Name='Owner';Expression={ (Get-Acl $_.FullName).Owner }}

Open in new window

1

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
Senior IT System EngineerIT ProfessionalCommented:
Yes it works good on my Windows 10 laptop:

......
Name          : Policy.1.0.Microsoft.Powershell.Security.dll
FullName      : C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Policy.1.0.Microsoft.PowerShell.Security\v4.0_1.0.0.0__31bf3856ad364e35\Policy.1.0.Microsoft.Powershell.Securi
                ty.dll
CreationDate  : 
LastWriteTime : 16/07/2016 9:44:14 PM
Owner         : NT SERVICE\TrustedInstaller

Get-ChildItem : Access to the path 'C:\Windows\ModemLogs' is denied.
At line:4 char:1
+ Get-ChildItem C:\Windows -Recurse |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\ModemLogs:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Get-ChildItem : Access to the path 'C:\Windows\PLA\Reports' is denied.
At line:4 char:1
+ Get-ChildItem C:\Windows -Recurse |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\PLA\Reports:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Get-ChildItem : Access to the path 'C:\Windows\PLA\Rules' is denied.
At line:4 char:1
+ Get-ChildItem C:\Windows -Recurse |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\PLA\Rules:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Get-ChildItem : Access to the path 'C:\Windows\PLA\Templates' is denied.
At line:4 char:1
+ Get-ChildItem C:\Windows -Recurse |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\PLA\Templates:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Name          : PowerShellExecutionPolicy.admx
FullName      : C:\Windows\PolicyDefinitions\PowerShellExecutionPolicy.admx
CreationDate  : 
LastWriteTime : 16/07/2016 9:44:14 PM
Owner         : NT SERVICE\TrustedInstaller
.....

Open in new window

0
MikeSecurityAuthor Commented:
I was able to use this command to and locate the files I needed , thanks
0
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.