Having a problem getting a filter argument to Get-ChildItem in a function
The following works fine and displays a whole list of files:
c:\temp\Get-ChildItem -Include deleteme.txt -Recurse
Now say I have the following script
file starts here
filename = GetLastFile.ps1
param([string] $filter)
$files = Get-ChildItem $filter
Write-Host $files #should print all matching files but prints nothing
$file = $files | Select-Object -Last 1;
$file.name #returns filename
file ends here
now trying to run the script>>
c:\temp.\GetLastFile.ps1 "-Include deleteme.txt -Recurse"
returns nothing.
suppling a filter . works fine, seems to be failing due to the -Include or -Exclude Any ideas?