I guess I could enter the extensions in an array and run though a loop
appending the results? Just wondering if there was an easier way
dir -path c:\data -Include @("*.txt","*.log") -rec
Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
a> Is there any way to run a get-childitem and filter for multiple
a> objects?
a> Example
a> Get-Childitem -path C:\ -filter *.log,*.txt
a> I guess I could enter the extensions in an array and run though a
a> loop appending the results? Just wondering if there was an easier
a> way
a>
You can with -include, just make sure to add the '*' wildcard to the end
of the path (it leads to the contents of the directory).
You can omit the wildcard if you specify -recurse:
PS > Get-Childitem -path C:\* -include *.log,*.txt
---
Shay Levy
Windows PowerShell MVP
blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic
a> Is there any way to run a get-childitem and filter for multiple
a> objects?
a> Example
a> Get-Childitem -path C:\ -filter *.log,*.txt
a> I guess I could enter the extensions in an array and run though a
a> loop appending the results? Just wondering if there was an easier
a> way
a>
If you check 'get-help get-childitem -full', you'll see that this
parameter only accepts a string. It also accepts a wildcard, which I
don't think will help.
You can also try this (less efficient):
get-childitem-path c:\ -recurse -include *.ps1,*.txt
(I'm using v2 CTP2, so if your results may be different if you're using v1.)
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
--
Kiron