Sign in
|
Join PowerShell.com!
|
Help
Home
PowerTips
Ask the Experts
Forums
Webcasts
Blogs
eBookV2
Script Library
Twitter Grid
Modules
QuickClick
Scripts
Snippets
Videos
Library
»
Script Library
»
Active Directory
»
Get-ADOU
Get-ADOU
Share
|
Browse Library
Module Library
QuickClick Library
Script Library
Active Directory
BizTalk
Citrix
Clustering
Desktop
Exchange Server 2003
Exchange Server 2007
File System
Group Policy
Internet Information Server (IIS)
Local Accounts
Logs
Microsoft Office
Microsoft Team Foundation Server
MySQL
Networking
Registry
Remote Desktop Services
Remoting
Security
SharePoint
SQL Server
System Center Virtual Machine Manager
System Center Configuration Manager
System Center Operations Manager
Tutorial
Terminal Server
Using .Net
Virtual Server
VMware
Windows 7
Windows HPC
Windows Server 2000
Windows Server 2003
Windows Server 2008
Windows XP
WMI
Misc
Snippet Library
Video Library
Members Only
Tags
Active Directory
ad
AD User
aman dhally
Computer
Deleted
DirectorySearcher
domain
Domain Controller
Exchange
Exchange 2003
Forest
Group
Local Administrators
Member
OU
Password
Powershell
powershell and active directory
Powershell Script
search
Security
Tombstone
User
WinNT:
View more
Previous
|
Next
|
View all files
|
View Slideshow
Download
posted by
Richard Giles
10-06-2008
Downloads: 428
File size: 1.2kB
Views: 2,196
Embed
Get-ADOU
## =====================================================================
## Title
: Get-ADContainerChildren
## Description : Get Active Directory Organizational Unit Children
## Author
: Idera
## Date
: 9/22/2008
## Input
: -server
##
-domain
##
-OU
##
-verbose
##
-debug
## Output
:
## Usage
: PS> . Get-OU -server localhost:389 -domain Idera
##
-OU sales -v -d
## Notes
: Adapted from Windows PowerShell Cookbook, Lee Holmes
## Tag
: PowerShell, AD
## Change log
:
## =====================================================================
param
(
[
string
]
$server
=
"localhost:389"
,
[
string
]
$domain
=
"Idera"
,
[
string
]
$OU
=
"sales"
,
[
switch
]
$verbose
,
[
switch
]
$debug
)
function
main()
{
if
(
$verbose
) {
$VerbosePreference
=
"Continue"
}
if
(
$debug
) {
$DebugPreference
=
"Continue"
}
Get-OU
$server
$domain
$OU
}
function
Get-OU
(
$server
,
$domain
,
$OU
)
{
trap
[
Exception
]
{
write-error
$
(
"TRAPPED: "
+
$_
.
Exception.Message
);
continue
;
}
$OrgUnit
=
[
adsi
]
"LDAP://$server/ou=$OU,dc=$domain,dc=COM"
$OrgUnit
.
PsBase.Children
}
main
Filed under:
Active Directory
,
OU
Get properties of an Active Directory Organizational Unit
Copyright 2012 PowerShell.com. All rights reserved.