Hi,
I am trying to get my head around a PS script which can list all the OU's (alongwith its child/grandchild OU's) in a text file.
The following script does the job halfway but the output is flat. i.e. it just lists all the OU's and nested OU's straight.
Get-ADOrganizationalUnit -Filter*|Select-Object-Property Name |Format-Table-AutoSize;
This will display a list looking something like below;
Name ---- Domain Controllers Microsoft Exchange Security Groups Security Groups Domain Servers Domain Workstations Domain Guest Accounts Printers Management Virtual Desktops IT Service Accounts Users Computers Production Servers SQL Servers Web Servers
However, what I am looking for is something like this in the report.
+ Domain Controllers
- Virtual
- 2008 R2
- 2012
- Physical
Microsoft Exchange Security Groups
Security Groups
Domain Servers
Domain Workstations
Domain Guest Accounts
Printers
Management
Virtual Desktops
IT
Service Accounts
Users
Computers
Production Servers
SQL Servers
Web Servers
HA