Category Archives: Powershell

Exchange 2010, show permission on all folders in all mailboxes

Here is a script, that runs though you Exchange server, and return all permission on all folders in all mailboxes.

The script needs to be running from the Exchange management Shell, and will create a subfolder in c:\ call ExchangeMailboxPermission, where it will create a text file for all yours mailboxes.

#This script will return all permissions on all folders
#in all mailboxes
#
#Written by Kenneth Dalbjerg - http://www.kennethdalbjerg.dk
#
$FolderPath = 'C:\ExchangeMailboxPermission\'
if ((Test-Path -path $FolderPath) -ne $True)
{
New-Item $FolderPath -type directory
}

$mailboxes = get-mailbox -resultsize unlimited
foreach ($mailbox in $mailboxes) {
$alias = $mailbox.DistinguishedName
$username = $mailbox.SamAccountName
$SpecialExchangeFolders = "Top of Information Store|Recoverable Items|Deletions|Purges|Versions"
$mailboxfolderes = Get-MailboxFolderStatistics -folderscope all -identity $alias | where { $_.name-notmatch $SpecialExchangeFolders }
$File = $FolderPath + '\' + $username + '.txt'
$mailboxfolderes | foreach {
$folder = $username + ':' + $_.folderpath -replace "/","\"
echo $folder
Get-MailboxFolderPermission -identity $folder
} | Out-file $File
}

Remove-RoutingGroupConnector – The operation couldn’t be performed because ‘rg-exchange’ matches multiple entries.

I have this problems that i could delete a routinggroup between an old Exchange 2003 and a new Exchange 2010.
When i type Get-RoutingGroupConnector

Name SourceRoutingGroup TargetRoutingGroup
—- —————— ——————
RG-Exchange Exchange Routing Group (DWBGZMFD01QNBJR) First Routing Group
RG-Exchange First Routing Group Exchange Routing Group (DWBGZMFD01QNBJR)

So i have 2 Routinggroup Connector with the same name. So when i type
Remove-RoutingGroupConnector -id “RG-Exchange”

I got
The operation couldn’t be performed because ‘rg-exchange’ matches multiple entries.
+ CategoryInfo : NotSpecified: (0:Int32) [Remove-RoutingGroupConnector], ManagementObjectAmbiguousExcepti
on
+ FullyQualifiedErrorId : 6C29C43B,Microsoft.Exchange.Management.SystemConfigurationTasks.RemoveRoutingGroupConnec
tor

So all i did was typing this instead:
get-routinggroupconnector -id “RG-Exchange” | remove-routinggroupconnector

Then it will ask you if you want to delete all routingsgroup with the name “RG-Exchange”

Powershell – Get all Security Groups from AD

First install http://www.quest.com/powershell/activeroles-server.aspx

Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue

$File = “C:\ita\securitygroups.txt”
$AllGroups = get-qadgroup -grouptype “Security” | select name, Description
$AllGroups | Foreach {
echo “”
echo “”
echo $_.name
echo $_.description
} | out-File $File