-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.PowerShell-Docs neededThe PR was reviewed and a PowerShell Docs update is neededThe PR was reviewed and a PowerShell Docs update is neededResolution-AnsweredThe question is answered.The question is answered.Resolution-By DesignThe reported behavior is by design.The reported behavior is by design.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I’m calling Get-ChildItem as shown below. I need it to skip folders in the directory tree that have the strings test, prototype or _vti in the name. None of the excluded folders are at the top of the tree.
Write-Host "Looking for new & changed files in $LocalRoot & subfolders"
$exclusions = @("*test*","*prototype*","*_vti*")
Write-Host "Exclusions: $exclusions`n"
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
$files = Get-ChildItem -Path $LocalRoot -Recurse -Attributes Archive -Exclude $exclusions
Before terminating, the script produces this output:
CONFIGURATION DATA:
LocalRoot=C:/Users/Dick/Documents/tch/site
ServerRoot=/
SiteNameInWinSCP=CyberHymnalSFTP
Looking for new & changed files in C:/Users/Dick/Documents/tch/site & subfolders
Exclusions: *test* *prototype* *_vti*
**```**
### Expected behavior
```console
The script should report the number of files found.
Actual behavior
The script aborts with an error after a few minutes
Error details
**Cannot bind parameter 'Property'. Cannot convert the "C:\Users\Dick\Documents\tch\site\img\b\e\e\s\_vti_cnf\beesley_e.jpg" value of type "System.IO.FileInfo" to type "Microsoft.PowerShell.Commands.PSPropertyExpression".**
As you can see, the file is in a folder named **_vti_cnf**, which should have been excluded from the search.
Is this a bug, or am I doing something wrong?
Environment data
Name Value
---- -----
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.PowerShell-Docs neededThe PR was reviewed and a PowerShell Docs update is neededThe PR was reviewed and a PowerShell Docs update is neededResolution-AnsweredThe question is answered.The question is answered.Resolution-By DesignThe reported behavior is by design.The reported behavior is by design.