3

I am new to PowerShell...

SL D:\SomeFolder get-childitem -exclude <D:\Somefolder\A> -recurse -Directory

I don't want d:\somefolder\A and its contents in the results, but for rest of the directories in "somefolder" I want recursive results.

I tried the command above, however, it is going inside the "\A" directory. It may be happening due to the -recurse switch, because if I don't use it...

Is there another way to achieve this?

Jamel Toms
  • 4,525
  • 2
  • 27
  • 26
  • "it may be happening due to recurse switch, coz if i dont use it... may be there is another way to achieve this" because if you don't use it ... what happens then? What should be on those dots? – wythagoras Aug 25 '16 at 12:59

1 Answers1

3

This lists children folders of D:\SomeFolder without D:\Somefolder\A:

get-childitem 'D:\SomeFolder' -recurse -Directory ` 
  | ? { $_.FullName -notlike 'D:\Somefolder\A*' }

See also here

Community
  • 1
  • 1
Anton Krouglov
  • 3,077
  • 2
  • 29
  • 50