The post Scanning Directories for Files with PowerShell appeared first on Patrick Domingues.
Learn how Scanning Directories for Files with PowerShell can help you locate specific files, making it easy to identify their paths, sizes, and modification dates.
Script Overview
The PowerShell script provided below searches for .xlsx
files starting from the root directory C:\
. It recursively scans through all subdirectories and returns a list of files that match the specified criteria. For each found file, it displays the full file path, file size, and the last modified date.
Get-ChildItem -Path C:\ -Recurse -Include *filenamehere.xlsx | Select-Object FullName, Length, LastWriteTime
Explanation of the Script
- Get-ChildItem: This cmdlet retrieves the items (files and directories) from a specified location. It can be used to list files and directories in a given path.
- **-Path C:**: This specifies the starting point for the search, which is the root directory
C:\
. You can change this to any directory you want to start your search from.