![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | get-childitem and exclude complete folder Hi, I try to report on some folders and must exclude some of them, but Get-ChildItem -path "C:\" -recurse -exclude "DFSReports" does not exclude the folder C:\DFSReports. Is there a workaround or am i missing something, Thanks a lot. |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: get-childitem and exclude complete folder On Nov 16, 12:06 am, Thomas Kofler <ThomasKof...@xxxxxx> wrote:
Returns the following (Note the "Doesn't work properly" part) -exclude <string[]> Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or patter n, such as "*.txt". Wildcards are permitted. This parameter does not work properly in this cmdlet. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? true You could try this. Get-Childitem -Path "C:" | Where {$_.PSisContainer -eq $false} Get-Childitem -Path "C:" | Where {$_.PSisContainer -eq $true} | Where {$_.name -ne "DFSReports"} | ForEach {Get-Childitem -Path $_ -Recurse} This gets you all of the items in all of the subdirectories under C:\ except "DFSReports". Hope that helps a bit. | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: get-childitem and exclude complete folder Thomas Kofler wrote:
-exclude <string[]> Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pa ttern, such as "*.txt". Wildcards are permitted. **This parameter does not work properly in this cmdlet.** What were you looking to do? You could possibly pipe this to a where-object or foreach-object cmdlet to drop the directories you don't want. Maco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | RE: get-childitem and exclude complete folder Thomas, I found that the problem is when is used C:\ with path, if you try to use another path C:\Test this work. Sorry, I know that I gave a solution, but another person gave a solution. Regards "Thomas Kofler" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: get-childitem and exclude complete folder Maybe this can help, its example #3 from the get-childitem help file (type: (get-help get-childitem).examples.example[2]) -------------------------- EXAMPLE 3 -------------------------- C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A* This command lists the .txt files in the Logs subdirectory, except for those whose names start with the letter A. It uses the wildcard character (*) to indicate the contents of the Logs subdirectory, not the directory container. Because the command does not include the Recurse parameter, Get-Childitem does not include the content of directory automatically; you need to specify it. Try: Get-ChildItem -path C:\* -exclude DFSReports -recurse ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get-childitem -exclude bug | bep | PowerShell | 7 | 03-11-2008 07:47 PM |
| Bug in Get-ChildItem -exclude | loworbit@gmail.com | PowerShell | 4 | 12-19-2006 05:58 PM |
| RE: Exclude directories from Get-ChildItem? | ~Clint | PowerShell | 0 | 11-29-2006 03:14 PM |
| RE: Exclude directories from Get-ChildItem? | RichS | PowerShell | 0 | 11-29-2006 01:30 PM |
| Exclude directories from Get-ChildItem? | ~Clint | PowerShell | 0 | 11-29-2006 12:47 PM |