One more question on -LiteralPath and -Include/-Exclude for GetChi

B

Bob Landau

The grammer for Get-ChildItem states that -Include/-Exclude are valid for
either the -Path or -LiteralPath parameter. Does anyone know whether this is
a documentation error or not?

From what I've seen either -Include or -Exclude is totally ignored. While
the below example is not useful; it is a simple example that illustrates the
behavor I'm seeing.

## works as expected
Get-ChildItem -path C:\windows\system32\* -include [xyz]*.dll

## returns nothing which I'm assuming is expected.
Get-ChildItem -path C:\windows\system32\ -include [xyz]*.dll

## fails '*' is an illegal character
Get-ChildItem -LiteralPath C:\windows\system32\* -include [xyz]*.dll

## returns everything in the System folder which makes no sense to me.
Get-ChildItem -LiteralPath C:\windows\system32\ -include [xyz]*.dll

## returns everything in the System folder and below which makes no sense to
me.
Get-ChildItem -LiteralPath C:\windows\system32\ -include [xyz]*.dll -recurse

In all these examples using 'LiteralPath', -Include and -Exclude can be used
interchangeable; the results are the same.

Lastly what does the helpfile mean in the -Exclude sub-section when it states?

'This parameter does not work properly in this cmdlet'


thx
bob
 

My Computer

K

Keith Hill [MVP]

"Bob Landau" <[email protected]> wrote in message
news:[email protected]

> The grammer for Get-ChildItem states that -Include/-Exclude are valid for
> either the -Path or -LiteralPath parameter. Does anyone know whether this
> is
> a documentation error or not?
Based on my understanding of how -Include/-Exclude work I would say that it
is a doc error. This issue blew up a little while before PS 1.0 shipped but
the team wasn't able to fix it in time for 1.0. IIRC -Include/-Exclude only
works with the -Path parameter and *only* when a wildcard is used within the
argument.

--
Keith
 

My Computer

W

Wassim Fayed [MSFT]

Hi Bob,
What you see is the expected behavior. Please look at the notes below from
the help contents on Get-Childitem:

-include <string[]>
Retrieves only the specified items. The value of this parameter
qualifies the Path parameter. Enter a path elem
ent or pattern, such as "*.txt". Wildcards are permitted.

The Include parameter is effective only when the command includes the
Recurse parameter or the path leads to th
e contents of a directory, such as C:\Windows\*, where the wildcard
character specifies the contents of the C:\
Windows directory.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true


Thanks
Wassim [MSFT]


"Bob Landau" <[email protected]> wrote in message
news:[email protected]

> The grammer for Get-ChildItem states that -Include/-Exclude are valid for
> either the -Path or -LiteralPath parameter. Does anyone know whether this
> is
> a documentation error or not?
>
> From what I've seen either -Include or -Exclude is totally ignored. While
> the below example is not useful; it is a simple example that illustrates
> the
> behavor I'm seeing.
>
> ## works as expected
> Get-ChildItem -path C:\windows\system32\* -include [xyz]*.dll
>
> ## returns nothing which I'm assuming is expected.
> Get-ChildItem -path C:\windows\system32\ -include [xyz]*.dll
>
> ## fails '*' is an illegal character
> Get-ChildItem -LiteralPath C:\windows\system32\* -include [xyz]*.dll
>
> ## returns everything in the System folder which makes no sense to me.
> Get-ChildItem -LiteralPath C:\windows\system32\ -include [xyz]*.dll
>
> ## returns everything in the System folder and below which makes no sense
> to
> me.
> Get-ChildItem -LiteralPath C:\windows\system32\ -include
> [xyz]*.dll -recurse
>
> In all these examples using 'LiteralPath', -Include and -Exclude can be
> used
> interchangeable; the results are the same.
>
> Lastly what does the helpfile mean in the -Exclude sub-section when it
> states?
>
> 'This parameter does not work properly in this cmdlet'
>
>
> thx
> bob
 

My Computer

B

Bob Landau

Re: One more question on -LiteralPath and -Include/-Exclude for Ge

Thanks for confirming what I suspected.

Hopefully in v2 Gci -LiteralPath will be enhanced to do basic file
operations such as looking for one or more specified files.

btw I did look at the helpfile. You've left at the punch line so I'll add it

NAME
Get-ChildItem

SYNOPSIS
Gets the items and child items in one or more specified locations.


SYNTAX
Get-ChildItem [[-path] <string[]>] [[-filter] <string>] [-include
<string[]>] [-exclude <string[]>] [-name] [-recurse] [-force]
[<CommonParameters>]

Get-ChildItem [-literalPath] <string[]> [[-filter] <string>] [-include
<string[]>] [-exclude <string[]>] [-name] [-recurse] [-force]
[<CommonParameters>]
<<<<<<


"Wassim Fayed [MSFT]" wrote:

> Hi Bob,
> What you see is the expected behavior. Please look at the notes below from
> the help contents on Get-Childitem:
>
> -include <string[]>
> Retrieves only the specified items. The value of this parameter
> qualifies the Path parameter. Enter a path elem
> ent or pattern, such as "*.txt". Wildcards are permitted.
>
> The Include parameter is effective only when the command includes the
> Recurse parameter or the path leads to th
> e contents of a directory, such as C:\Windows\*, where the wildcard
> character specifies the contents of the C:\
> Windows directory.
>
> Required? false
> Position? named
> Default value
> Accept pipeline input? false
> Accept wildcard characters? true
>
> -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.
>
> Required? false
> Position? named
> Default value
> Accept pipeline input? false
> Accept wildcard characters? true
>
>
> Thanks
> Wassim [MSFT]
>
>
> "Bob Landau" <[email protected]> wrote in message
> news:[email protected]

> > The grammer for Get-ChildItem states that -Include/-Exclude are valid for
> > either the -Path or -LiteralPath parameter. Does anyone know whether this
> > is
> > a documentation error or not?
> >
> > From what I've seen either -Include or -Exclude is totally ignored. While
> > the below example is not useful; it is a simple example that illustrates
> > the
> > behavor I'm seeing.
> >
> > ## works as expected
> > Get-ChildItem -path C:\windows\system32\* -include [xyz]*.dll
> >
> > ## returns nothing which I'm assuming is expected.
> > Get-ChildItem -path C:\windows\system32\ -include [xyz]*.dll
> >
> > ## fails '*' is an illegal character
> > Get-ChildItem -LiteralPath C:\windows\system32\* -include [xyz]*.dll
> >
> > ## returns everything in the System folder which makes no sense to me.
> > Get-ChildItem -LiteralPath C:\windows\system32\ -include [xyz]*.dll
> >
> > ## returns everything in the System folder and below which makes no sense
> > to
> > me.
> > Get-ChildItem -LiteralPath C:\windows\system32\ -include
> > [xyz]*.dll -recurse
> >
> > In all these examples using 'LiteralPath', -Include and -Exclude can be
> > used
> > interchangeable; the results are the same.
> >
> > Lastly what does the helpfile mean in the -Exclude sub-section when it
> > states?
> >
> > 'This parameter does not work properly in this cmdlet'
> >
> >
> > thx
> > bob
>
>
 

My Computer

B

Bob Landau

Re: One more question on -LiteralPath and -Include/-Exclude for Ge

Thanks Keith,

While I have to admit I've not found much use for these "odd" directory
names it would have been nice to be able to at least specify which set of
files/file to check for.

"Keith Hill [MVP]" wrote:

> "Bob Landau" <[email protected]> wrote in message
> news:[email protected]

> > The grammer for Get-ChildItem states that -Include/-Exclude are valid for
> > either the -Path or -LiteralPath parameter. Does anyone know whether this
> > is
> > a documentation error or not?
>
> Based on my understanding of how -Include/-Exclude work I would say that it
> is a doc error. This issue blew up a little while before PS 1.0 shipped but
> the team wasn't able to fix it in time for 1.0. IIRC -Include/-Exclude only
> works with the -Path parameter and *only* when a wildcard is used within the
> argument.
>
> --
> Keith
>
>
 

My Computer

Top