cancervic
asked on
How to identify empty or unused dist/sec groups and mailboxes.
Hi,
I am looking for a way which i can generate a list of empty or unused AD distribution and Security groups and a generate a list of unused mailboxes.
David
I am looking for a way which i can generate a list of empty or unused AD distribution and Security groups and a generate a list of unused mailboxes.
David
ASKER
thanks.
Where and how is this script executed ? do i save it as a batch file ?
does this do security groups also ?
Where and how is this script executed ? do i save it as a batch file ?
does this do security groups also ?
Well the first one goes to a link (http://gsexdev.blogspot.com/2006/05/finding-and-removing-empty.html)...which runs as a VBS. Just rename to emptdist.vbs
The second one is put in a .ps1 file which is just a notepad and just remove .txt to .ps1 - But you need Powershell
emptdist.vbs.txt
The second one is put in a .ps1 file which is just a notepad and just remove .txt to .ps1 - But you need Powershell
emptdist.vbs.txt
ASKER
Hi,
i downloaded windows powershell 1.0. How do i execute the script. I copied the script above into a text file, renamed as example.ps1. and saved it under c:\., I opened up windows powershell 1.0 and at the prompt entered example.ps1
"The term 'example.ps1' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:11
+ example.ps1 <<<<"
any suggestions ?
i downloaded windows powershell 1.0. How do i execute the script. I copied the script above into a text file, renamed as example.ps1. and saved it under c:\., I opened up windows powershell 1.0 and at the prompt entered example.ps1
"The term 'example.ps1' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:11
+ example.ps1 <<<<"
any suggestions ?
ASKER
Got it to work, now i am facing with this:
The term 'Get-DistributionGroup' is not recognized as a cmdlet, function, operable program, or script file. Verify the
term and try again.
At C:\empty.ps1:1 char:32
+ $groups = Get-DistributionGroup <<<<
The term 'Get-DistributionGroupMemb er' is not recognized as a cmdlet, function, operable program, or script file. Verif
y the term and try again.
At C:\empty.ps1:5 char:43
+ $groupMem = Get-DistributionGroupMembe r <<<< $a
The term 'Get-DistributionGroup' is not recognized as a cmdlet, function, operable program, or script file. Verify the
term and try again.
At C:\empty.ps1:1 char:32
+ $groups = Get-DistributionGroup <<<<
The term 'Get-DistributionGroupMemb
y the term and try again.
At C:\empty.ps1:5 char:43
+ $groupMem = Get-DistributionGroupMembe
You'd need Exchange 2007 to be able to use Get-DistributionGroup and Get-DistributionGroupMembe
You can find empty groups easily enough though. You can do that in AD Users and Computers if you wish with this query:
(&(objectCategory=group)(!
Perhaps the easiest place to put it is...
Right click and Find
Select "Custom Search" from the drop down box
Select Advanced
Enter the LDAP Filter above and hit Find Now
Or if you grabbed these to go with PowerShell:
http://www.quest.com/activeroles-server/arms.aspx
Then you could run:
Get-QADGroup -LdapFilter "(&(objectCategory=group)(
Unused is a bit more difficult, it depends on your definition of unused. Any idea what criteria you would use?
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://gsexdev.blogspot.com/2006/05/finding-and-removing-empty.html
Or use powershell which is the good way to run queries:
Save to .ps1 and run with .\filename.ps1.
$groups = Get-DistributionGroup
$amount = @()
foreach ($a in $groups)
{
$groupMem = Get-DistributionGroupMembe
if ($groupMem.Count -eq $null) { $amount += $a }
}
Write-Output $amount | Select-Object Name,GroupType,Organizatio
http://forums.msexchange.org/m_1800490641/tm.htm