Discussion:
get-childitem . -Name | where {$_.PsIsContainer} not working in 1.
(too old to reply)
brato
2007-03-09 19:46:03 UTC
Permalink
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
George Davis
2007-03-09 20:08:39 UTC
Permalink
The following gets all sub-directories of the current folder:

get-childitem | where {$_.PsIsContainer}

--George
Post by brato
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
brato
2007-03-09 20:17:03 UTC
Permalink
No I want only the directory names. So the one below dosen't work for me.
-Name returns only the directory names.

Thanks,
Bharat
Post by George Davis
get-childitem | where {$_.PsIsContainer}
--George
Post by brato
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
RichS
2007-03-09 20:49:08 UTC
Permalink
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
Post by brato
No I want only the directory names. So the one below dosen't work for me.
-Name returns only the directory names.
Thanks,
Bharat
Post by George Davis
get-childitem | where {$_.PsIsContainer}
--George
Post by brato
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
Keith Hill [MVP]
2007-03-09 21:17:59 UTC
Permalink
Post by RichS
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
Flowering Weeds
2007-03-11 21:22:27 UTC
Permalink
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

Loading...