PowerShell: Browse for a File With PowerShell and Find Its Full Path

IT pros often have to perform routine file management tasks such as finding data and then moving or deleting it. With manual methods, these tasks take up a lot of time, so you might want to automate them with Windows PowerShell scripts and commands. For instance, the PowerShell script provided above enables you to find all files on your share that have a particular word in their name by using the Get-ChildItem cmdlet. 

  1. Open the PowerShell ISE → Create a new script using the following code:

    $filename = '*payroll*.*'#you can use wildcards here for name and for extension
    $searchinfolder = '\\pdc\Shared\Accounting*'
    Get-ChildItem -Path $searchinfolder -Filter $filename -Recurse | %{$_.FullName}
    
  2.  Specify the name of file in question ($filename) and directory or folder ($searchinfolder) to search in.

  3. Run the script.

  4. Review the results:

    https://img.netwrix.com/howtos/powershell_find_file.png

Credits

Originally published at: https://www.netwrix.com/how_to_find_a_file_and_check_if_it_exists.html