Hi all
I would like to know all empty OU existing on my AD.
I found a powershell command line below which retrieve this information:
Get-ADOrganizationalUnit -Filter | ForEach-Object {
if (-not (Get-ADObject -SearchBase $_ -SearchScope OneLevel -Filter ))
{
$.Name +";;;;;;;;;;;;;;;;;;;;;;;;;"+$.DistinguishedName
}
}
This command works but it's not optimal. for example I would like to export to csv file with "export-csv -path filename.csv" and it doesn't work.
Idon't feel comfortable with powershell..
Does someone can help me to improve this script and export it. Or maybe somebody has something better in what I need?
Thank you by advance.
Mohamed

