Created
April 11, 2012 17:28
-
-
Save danielmoore/2360734 to your computer and use it in GitHub Desktop.
Find-File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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