Avatar of jacksonwsa
 asked on

PowerShell search script

I am looking for a script that will search a specific directory for .mdb and .accdb files. I would like it to export to csv and have the following information included.
- file name with full path
- owner
- date last accessed
- size
Microsoft Legacy OS

Avatar of undefined
Last Comment

8/22/2022 - Mon
Sharath S

check if this fits your requirement: http://powershellcommunity.org/Forums/tabid/54/aft/7208/Default.aspx

Get-ChildItem -Path $SearchPath |
Where-Object { $_.PSIsContainer } |
Select-Object -ExpandProperty FullName |
Out-File -FilePath $FolderFilePath

Get-Content -Path $FolderFilePath |
Get-ChildItem -Path { $_ } -Include *.mdb, *.accdb -Recurse -Force |
Select-Object -Property @(
    ,@{ Name = 'Size(KB)'                ; Expression = { $_.Length / 1kb } }
    ,@{ Name = 'Owner'                   ; Expression = { (Get-Acl -Path $_.FullName).Owner } }
    ,@{ Name = 'Days since modified'     ; Expression = { ((Get-Date) - $_.LastWriteTime).Days } }
    ,@{ Name = 'Age -days since created' ; Expression = { ((Get-Date) - $_.CreationTime).Days } }
) | Export-Csv -Path $ResultFilePath -NoTypeInformation

I can't get this to work. Trying to run this against c:\test directory. and don't care where the output file goes.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes