Category Archives: Windows Server

PowerShell Search For Specific Files

One of our systems used old, inefficient technology (you have systems like that, right?).  The system would drop thousands of files into a folder to be reviewed and relocated based on criteria provided by the finance team.  Our developers were working on a way to add automation to the process, but it was not a high priority project.

Until the automation project could be completed, the finance team asked if we could help by setting up a system to parse through the files and provide them with a daily report of unprocessed files.

I created and scheduled a PowerShell search script based on the requirements which would find the unprocessed files, export the data to a .csv report file and send an e-mail to the team with the location of the daily report.  Problem solved.

Below is the PowerShell code that I used to make it happen.

$Path = "\\dom\shares\prod\fin"
Get-ChildItem -Path $path -Filter "*op*.txt" -Recurse `
| Select-Object -Property Name, DirectoryName, @{Name="Size (KB)"; Expression={"{0:0.00}"-f $_.length/1024 }}, LastWriteTime `
| Export-Csv "\\dom\shares\prod\fin\report\UnprocessedDailyReport.csv" -NoTypeInformation