Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions PSItems/Public/Find-Item.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
[CmdletBinding()]
[OutputType('System.String', 'System.IO.FileSystemInfo')]
param (
# Path to search for files
# Path to search for files. Defaults to current directory.
[Parameter(Mandatory = $false, Position = 0)]
[string]
$Path = $pwd,
Expand Down Expand Up @@ -166,15 +166,19 @@
}

try {
# Resolve absolute path in case it is relative
[ref] $dummy = $null
$absolutePath = $PSCmdlet.GetResolvedProviderPathFromPSPath($Path, $dummy)[0]
# if more than one string was given use foreach (so if input $Name is a string array)
foreach ($input in $Name) {
foreach ($item in [System.IO.Directory]::$($Method)($path, $input, $EnumerationOptions)) {
foreach ($item in [System.IO.Directory]::$($Method)($absolutePath, $input, $EnumerationOptions)) {
if ($As -eq 'FileInfo') { $file = [System.IO.FileInfo]::new($item) } else { $file = [string]::new($item) }
Write-Output $file
}
}
} catch {
throw $_.Exception.Message
Write-Error $_
return
}
}

Expand Down
Loading