How can I use PowerShell's -filter parameter to exclude values/files?

我们两清 提交于 2019-12-04 03:26:39
CB.

-Filter is not the right way. Use the -exclude parameter instead:

$srcfiles = Get-ChildItem $srcPath -exclude *.htm*

-exclude accepts a string[] type as an input. In that way you can exclude more than one extension/file type as follows:

 $srcfiles = Get-ChildItem $srcPath -exclude *.htm*,*.css,*.doc*,*.xls*

..And so on.

I am a little newer to PowerShell, but could you pipe to the where command?

$srcfiles = Get-ChildItem $srcPath | where-object {$_.extension -ne "*.htm*"}

I am not sure what the actually property you would use in place "extension" is though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!