Thursday, September 13, 2012

Find Files Using Powershell.

Hi,
This seems a easy Topic, but as you know in my articles i always tries to cover tasks rather then techniques.  The main benefits of these kind of articles is they help in quick learning.

The more you use the more you learn.

Today i was looking for some files  and when i open Windows Search and see that few of my Drives are not indexed by windows Search, and it is taking a time to give the results.

And at that time i think , lets try to use Powershell to search for a file. 

and i used the below command to achieve my target.

Get-ChildItem -Recurse d:\ | Where-Object { ($_.PSIsContainer -eq $false) -and ( $_.Name -like "*Active*" )}

13-09-2012 12-25-55
In Above Command . Using Get-ChildItem -Recurse i am searching for all folders and subfolders in D Drive and then we are piping the output to Where-Object Cmdlet and we are we are defining two conditions here. one the PSIsContainer should be $false that means this should be a file and after that we are defining the name of the  File which we want to search,

I converted the above in to the script,  you can download the script from below link.

Download Link : https://dl.dropbox.com/u/17858935/Find_Files_Using_Powershell.zip

In this script i added read-host , so when you runt he script it ask you for FILE path to search and the File name to search and after that i will give you the result.

13-09-2012 11-50-44

Download Link : https://dl.dropbox.com/u/17858935/Find_Files_Using_Powershell.zip
Thanks
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

1 comment:

  1. Hi, I'm trying to also get the Product Version of the found files to display but i'm having trouble. Here is the code I'm trying to merger into yours:

    $_ | Add-Member NoteProperty ProductVersion ($_.VersionInfo.ProductVersion)

    Hope you can help.

    Thanks

    ReplyDelete

Note: Only a member of this blog may post a comment.