Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - get-childitem . -Name | where {$_.PsIsContainer} not working in 1.

Reply
 
Old 03-09-2007   #1 (permalink)
brato


 
 

get-childitem . -Name | where {$_.PsIsContainer} not working in 1.

Hi,

The following command works on RC1 and RC2, but it dosen't work on the
powershell 1.0 release.

get-childitem . -Name | where {$_.PsIsContainer}

This above command returns all directories only. This dosen't return any
results in powershell 1.0. Does anyone know if this is a bug and how can I
overcome this.

Thanks,
Bharat

My System SpecsSystem Spec
Old 03-09-2007   #2 (permalink)
George Davis


 
 

RE: get-childitem . -Name | where {$_.PsIsContainer} not working in 1.

The following gets all sub-directories of the current folder:

get-childitem | where {$_.PsIsContainer}

--George

"brato" wrote:

> Hi,
>
> The following command works on RC1 and RC2, but it dosen't work on the
> powershell 1.0 release.
>
> get-childitem . -Name | where {$_.PsIsContainer}
>
> This above command returns all directories only. This dosen't return any
> results in powershell 1.0. Does anyone know if this is a bug and how can I
> overcome this.
>
> Thanks,
> Bharat

My System SpecsSystem Spec
Old 03-09-2007   #3 (permalink)
brato


 
 

RE: get-childitem . -Name | where {$_.PsIsContainer} not working i

No I want only the directory names. So the one below dosen't work for me.
-Name returns only the directory names.

Thanks,
Bharat

"George Davis" wrote:

> The following gets all sub-directories of the current folder:
>
> get-childitem | where {$_.PsIsContainer}
>
> --George
>
> "brato" wrote:
>
> > Hi,
> >
> > The following command works on RC1 and RC2, but it dosen't work on the
> > powershell 1.0 release.
> >
> > get-childitem . -Name | where {$_.PsIsContainer}
> >
> > This above command returns all directories only. This dosen't return any
> > results in powershell 1.0. Does anyone know if this is a bug and how can I
> > overcome this.
> >
> > Thanks,
> > Bharat

My System SpecsSystem Spec
Old 03-09-2007   #4 (permalink)
RichS


 
 

RE: get-childitem . -Name | where {$_.PsIsContainer} not working i

Get-ChildItem . | where{$_.Psiscontainer} | select name

will do what you want. According to the help file on get-childitem if you
use -name it will only pass the name into the pipeline which is why you can't
then use the where cmdlet
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"brato" wrote:

> No I want only the directory names. So the one below dosen't work for me.
> -Name returns only the directory names.
>
> Thanks,
> Bharat
>
> "George Davis" wrote:
>
> > The following gets all sub-directories of the current folder:
> >
> > get-childitem | where {$_.PsIsContainer}
> >
> > --George
> >
> > "brato" wrote:
> >
> > > Hi,
> > >
> > > The following command works on RC1 and RC2, but it dosen't work on the
> > > powershell 1.0 release.
> > >
> > > get-childitem . -Name | where {$_.PsIsContainer}
> > >
> > > This above command returns all directories only. This dosen't return any
> > > results in powershell 1.0. Does anyone know if this is a bug and how can I
> > > overcome this.
> > >
> > > Thanks,
> > > Bharat

My System SpecsSystem Spec
Old 03-09-2007   #5 (permalink)
Keith Hill [MVP]


 
 

Re: get-childitem . -Name | where {$_.PsIsContainer} not working i

"RichS" <RichS@discussions.microsoft.com> wrote in message
news:0680228B-1115-4DAF-9F91-512272A50AB0@microsoft.com...
> Get-ChildItem . | where{$_.Psiscontainer} | select name
>
> will do what you want. According to the help file on get-childitem if you
> use -name it will only pass the name into the pipeline which is why you
> can't
> then use the where cmdlet


Yep that name is passed as a string type which doens't have a PSIsContainer
property. Rich's approach is the one I would take.

--
Keith


My System SpecsSystem Spec
Old 03-11-2007   #6 (permalink)
Flowering Weeds


 
 

Re: get-childitem . -Name | where {$_.PsIsContainer} not working i


Another way

Perhaps Microsoft's Log Parser 2.2

PS> LogParser -h -i:fs

Input format: FS (FileSystem properties)
Returns properties of files and folders



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
get-childitem -exclude bug PowerShell
get-childitem bug? PowerShell
using Get-ChildItem PowerShell
get-childitem PowerShell
Problem with Get-ChildItem PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46