This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Find-File

Synopsis

Finds files on a remote computer.

Syntax

  • Find-File [-FileName] [-StartPath] [-ComputerName] [-Credential]

Description

Find-File is used to find files across the local drives of a remote computer. File names can be specified using wildcards and searches narrowed by using the StartPath parameter.

File searches are performed by filename only. Increasing the accuracy of the file name by removing wildcards and providing file extensions shortens search time and reduces load on the searching computer.

Parameters

  • FileName The file name to search for. File names may contain wildcards.
  • StartPath The path from which to start the search.
  • ComputerName The computer that will run the search.
  • Credential The credentials used to perform the search. Results will only be shown for files for which the executing user has rights.

Inputs

Find-File accepts pipeline input for the ComputerName parameter and requires that the input object contain a property named either Computer, CN or ComputerName.

Outputs

Find-File returns a Vexasoft.FileInfo object for each matched file on the target computer.

Notes

The cmdlet requires that the Remote Registry and RPC services are started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will find all files named install.log on remote computer PC01:

c:\PS>Find-File install.log -ComputerName PC01

Example 2

Wildcards can be used in searches. This command will find all files with the extension "log" on remote computer PC01:

c:\PS>Find-File *.log -ComputerName PC01

Example 3

The StartPath parameter can be used to limit results and speed up the search. This command will find all files with the extension "log" in c:\windows\temp and all subdirectories on remote computer PC01.

c:\PS>Find-File *.log -StartPath c:\windows\temp -ComputerName PC01

Example 4

The StartPath parameter does not need to be specific to a particular drive. This command will find all files with the extension "log" in the Users directory and all subdirectories across all drives on remote computer Server01.

c:\PS>Find-File *.log -StartPath \Users -ComputerName Server01