I want to have a CSV file for all users in a specific Organizational Unit and have that for all OU's witin the domain /forest
Will the following work and/or where would I improve and/or change the script?
$OutputFile = 'C:\Users\Public\Documents\OuStructure.txt'
$InputtFile = 'C:\Users\Public\Documents\MailboxStatistics-'+(Get-Content $OutputFile).ToString+'.csv'Foreach ($GetOu in (Get-Content $OutputFile))
{Get-Mailbox -ResultSize Unlimited |Where-Object {$_.OrganizationalUnit -like $GetOu -and $_.Database -notlike 'DB0*' }|Select-Object DisplayName,Alias,OrganizationalUnit,Database,PrimarySMTP*,Recipient* |Sort-Object OrganizationalUnit ` |Export-Csv -Path $InputtFile}
Cheers, Andor