Tag Archives: powershell

Get mailboxes and witch groups there are member of

I need to get all mailboxes, and witch group there are member of.

You need Quest ActiveRoles Management Shell for this to work:
http://www.quest.com/powershell/activeroles-server.aspx

Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue

$File = "C:\groupslog.txt"
$Mailboxes = Get-mailbox -resultsize unlimited | select sAMAccountName,name,alias
$Mailboxes | ForEach {
   $User = Get-QADUser -samaccountname $_.sAMAccountName | Select sAMAccountName, memberOf
   $Line = $_.sAMAccountName
   ForEach ($GroupDN In $User.memberOf)
   {
      $Group = (Get-QADGroup $GroupDN | Select sAMAccountName).sAMAccountName
      $Line = "$Line,$Group"
   }
   echo $Line
} | out-File $File

In the file c:\groupslog.txt each line is a mailbox, and the first entry is the sAMAccountName, and each entry after this is the group the Mailbox is member of.

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
}

Exchange 2010, powershell full access and send-as permission

To get a CSV file, from you exchange with full access and send as permission, from all you mailboxes run these commands:

Full Access

Get-Mailbox | Get-MailboxPermission | where {$_.user.tostring() -ne “NT AUTHORITY\SELF” -and $_.IsInherited -eq $false} | Select Identity,User,@{Name=’Access Rights’;Expression={[string]::join(‘, ‘, $_.AccessRights)}} | Export-Csv -NoTypeInformation c:\mailboxpermissions.csv

Send As

Get-Mailbox | Get-ADPermission | where { ($_.ExtendedRights -like “*Send-As*”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | Select Identity, User, Deny | Export-CSVc:\sendas.csv

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