Solved

modify a powershell command get-childitem

Posted on 2013-01-25
5
422 Views
Last Modified: 2013-01-28
Hello,

How to change this powershell command to exclude directories containing files flag.txt ?

$folders=Get-ChildItem  | Foreach-Object { Get-ChildItem $_ | Where-Object {$_.psiscontainer}} | % { "$($_.fullname)"}|  Sort-Object -descending

Thanks

bibi
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38820187
Try.. You may remove the -Recurse if required, so it will not search the sub directories..
$folders = Get-ChildItem -Recurse |?{$_.psiscontainer} | % {If ((GCI "$($_.fullname)\*" -Include "flag.txt") -eq $null){$_.fullname}}

Open in new window

0
 

Author Comment

by:bibi92
ID: 38826355
Thanks, it takes too much time
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38826384
If you want to do recursive search in directory then it will take time depends on the file count...
0
 

Author Comment

by:bibi92
ID: 38826401
Exactly thanks
0
 

Author Closing Comment

by:bibi92
ID: 38826402
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question