Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

List ONLY OUs

$
0
0

Hi

I like out-GridView. It rocks my world.

What I'm trying to do is list sub-OUs of an OU, which I can do like this:

Powershell
dir|Out-GridView

But within this OU there are a couple of objects that aren't OUs. I don't want to see them. I've tried various versions of using where:
Powershell
dir|where{$_.ObjectClass-eorganizationalUnit}

Or...
Powershell
dir|where{$_.ObjectClass-e"organizationalUnit"}

But to no avail. The first gives out this:
Text
At line:1 char:29 + dir | where {$_.ObjectClass -e organizationalUnit} + ~~ Unexpected token '-e' in expression or statement. At line:1 char:32 + dir | where {$_.ObjectClass -e organizationalUnit} + ~~~~~~~~~~~~~~~~~~ Unexpected token 'organizationalUnit' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId :...

Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>