For thefirst part, please refer to http://powergui.org/thread.jspa?threadID=2701&tstart=0. (This post providesinformation on how you can use Management Shell for AD from Quest Software todo various management tasks for your Active Directory. For a quick introductioninto Management Shell for AD, please refer to: http://powergui.org/thread.jspa?threadID=2700&tstart=0) Let's try somethingreal. For alluser accounts, let's count users for each department: (I reallyrecommend trying 100 as size limit first) PSC:\> Get-QADUser -sl 1000000 | Group-Object -property Department -noelement| Sort-Object -Descending -Property Count CountName --------- 623 R&D 588 296 Marketing 292 Presales 284 Inside/Geo/Reg Sales 222 Support 170 Consulting Services 124 Named Accounts 107 Management-Sales 92 Admin-Sales 81 General Accounting 80 Channels [...] What we didhere, we build a list of all users in domain, then group them by Departmentproperty using build-in cmdlet Group-Object and then sort the results descendingby count. To sort bydepartment name, execute the following: Get-QADUser-sl 1000000 | Group-Object -property Department -noelement | Sort-Object -PropertyName We can dothe same for other attributes. Let's seehow many employees are working in each city: PS C:\>Get-QADUser -sl 1000000 | Group-Object -property City-noelement | Sort-Object -Descending -Property Count Count Name ----- ---- 160 NewYork 58 Toronto 31 Warrenville [...] To countmailboxes per each mailbox store, use homeMDB attribute. As homeMDB does not presentedin default property list returned by Get-QADUser cmdlet, use the {$_.DirectoryEntry.homeMDB}as property name for the workaround: PS C:\>Get-QADUser -sl 100 | Group-Object -property {$_.DirectoryEntry.homeMDB}-noelement | Sort-Object -Descending -Property Count Count Name ----- ---- 48 7 CN=Mailbox Store (IRVP... 5 CN=Mailbox Store 3 (AL... 5 CN=Mailbox Store (UKBM... 5 CN=Mailbox Store 3 (AL... 4 CN=Mailbox Store 3 (NY... A quick explanationfor the "{$_.DirectoryEntry.homeMDB}"here. This is actually a very small piece of code that first access the DirectoryEntryproperty of the object passed though the pipe (the object returned byGet-QADUser cmdlet). Then, it access the homeMDB property of theDirectoryEntry. With this workaround you can access any AD attribute.
|