
Learn the way Scanning Directories for Information with PowerShell will help you find particular recordsdata, making it straightforward to establish their paths, sizes, and modification dates.
Script Overview
The PowerShell script supplied beneath searches for .xlsx
recordsdata ranging from the foundation listing C:
. It recursively scans via all subdirectories and returns a listing of recordsdata that match the required standards. For every discovered file, it shows the total file path, file measurement, and the final modified date.
Get-ChildItem -Path C: -Recurse -Embody *filenamehere.xlsx | Choose-Object FullName, Size, LastWriteTime
Rationalization of the Script
- Get-ChildItem: This cmdlet retrieves the objects (recordsdata and directories) from a specified location. It may be used to listing recordsdata and directories in a given path.
- **-Path C:**: This specifies the start line for the search, which is the foundation listing
C:
. You may change this to any listing you wish to begin your search from. - -Recurse: This parameter tells PowerShell to incorporate all subdirectories within the search. With out this parameter, solely the recordsdata within the specified listing can be listed.
- *-Embody filenamehere.xlsx: This parameter filters the outcomes to incorporate solely the recordsdata that match the required sample. Change
*filenamehere.xlsx
along with your desired file sample. The asterisk*
is a wildcard that matches any sequence of characters. - Choose-Object FullName, Size, LastWriteTime: This cmdlet is used to pick particular properties of the objects returned by
Get-ChildItem
. Right here, it selects the total path (FullName
), file measurement in bytes (Size
), and the final modified date and time (LastWriteTime
).
Use the Script
- Open PowerShell: Launch PowerShell in your Home windows machine. You are able to do this by looking for “PowerShell” within the Begin menu.
- Run the Script: Copy the script and paste it into the PowerShell window. Press
Enter
to execute. - Assessment the Output: The script will listing all
.xlsx
recordsdata ranging from the foundation listing, displaying their full paths, sizes, and final modified dates.
Customizing the Script
- Change the File Sort: If you happen to’re searching for a special sort of file, merely exchange
*.xlsx
with the specified file extension (e.g.,*.docx
for Phrase paperwork). - Specify a Completely different Path: To go looking in a special listing, change
-Path C:
to the trail of the specified listing (e.g.,-Path D:Paperwork
).
Conclusion
By using this PowerShell script, yow will discover particular recordsdata throughout directories. It’s a fantastic script to shortly discover recordsdata you’re searching for.
Associated
Uncover extra from Patrick Domingues
Subscribe to get the most recent posts despatched to your e mail.