Skip to content

Instantly share code, notes, and snippets.

@danielmoore
Created April 11, 2012 17:28
Show Gist options
  • Save danielmoore/2360734 to your computer and use it in GitHub Desktop.
Save danielmoore/2360734 to your computer and use it in GitHub Desktop.
Find-File
function Find-File {
[CmdletBinding(DefaultParameterSetName = 'Count')]
param(
[Parameter(Mandatory = $true, Position = 0)]
[string]$Name,
[Parameter(Position = 1)]
[string]$Directory = '.',
[Parameter(ParameterSetName = 'Count')]
[int]$MaxResults = 1,
[Parameter(ParameterSetName = 'All')]
[Switch]$All
)
$selectArgs = @{ ExpandProperty = 'FullName' }
if (-not $All) { $selectArgs['First'] = $MaxResults }
ls $Directory $Name -Recurse | select @selectArgs
}
Set-Alias find Find-File
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment