[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

modify a powershell command get-childitem

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
bibi92
Asked:
bibi92
  • 3
  • 2
1 Solution
 
SubsunCommented:
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
 
bibi92Author Commented:
Thanks, it takes too much time
0
 
SubsunCommented:
If you want to do recursive search in directory then it will take time depends on the file count...
0
 
bibi92Author Commented:
Exactly thanks
0
 
bibi92Author Commented:
Thanks
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now