Avatar of jacksonwsa
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
TaskmasterDan
Avatar of Sharath S
Sharath S
Flag of United States of America image

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'
    ,'FullName'
    ,@{ Name = 'Size(KB)'                ; Expression = { $_.Length / 1kb } }
    ,@{ Name = 'Owner'                   ; Expression = { (Get-Acl -Path $_.FullName).Owner } }
    ,'LastWriteTime'
    ,@{ Name = 'Days since modified'     ; Expression = { ((Get-Date) - $_.LastWriteTime).Days } }
    ,@{ Name = 'Age -days since created' ; Expression = { ((Get-Date) - $_.CreationTime).Days } }
) | Export-Csv -Path $ResultFilePath -NoTypeInformation
Avatar of jacksonwsa
jacksonwsa

ASKER

I can't get this to work. Trying to run this against c:\test directory. and don't care where the output file goes.
ASKER CERTIFIED SOLUTION
Avatar of TaskmasterDan
TaskmasterDan
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft Legacy OS
Microsoft Legacy OS

The Microsoft Legacy Operating System topic includes legacy versions of Microsoft operating systems prior to Windows 2000: All versions of MS-DOS and other versions developed for specific manufacturers and Windows 3/3.1, Windows 95 and Windows 98, plus any other Windows-related versions, and Windows Mobile.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo