Reputation: 21
Get-childItem | Where-Object { ($_.CreationTime).ToString('dd/MM/yyyy') -EQ 01/01/2017}
How do you create exceptions when listing files ? So if I want to list every file in a directory apart from files called "File 1
" and "File 2
"
Upvotes: 0
Views: 1036
Reputation: 169
Either of the above examples will work, it's more of a preference. I personally like to do as much filtering of the data before I pass it along the pipeline.
Upvotes: 0
Reputation: 171
Get-childItem | Where-Object {$_.Name -ne 'file 1' -and $_.name -ne 'file 2'}
Upvotes: 0
Reputation: 10044
Using the -Exclude
parameter on Get-ChildItem
:
Get-ChildItem -Exclude File1,File2 | Where-Object { ($_.CreationTime).ToString('dd/MM/yyyy') -EQ 01/01/2017}
Upvotes: 2