Windows/exchange: Unterschied zwischen den Versionen

Aus SchnallIchNet
Wechseln zu: Navigation, Suche
Zeile 139: Zeile 139:
  Get-MailboxFolderPermission "USER:\Kalender" | Foreach-Object { $_.identity.adrecipient.identity }
  Get-MailboxFolderPermission "USER:\Kalender" | Foreach-Object { $_.identity.adrecipient.identity }
=== set Sent-Folder for group mailboxes ===
Set-MailboxSentItemsConfiguration <alias> -SendAsItemsCopiedTo SenderAndFrom -SendOnBehalfOfItemsCopiedTo SenderAndFrom
=== enable autoreply / vacation message ===
=== enable autoreply / vacation message ===

Aktuelle Version vom 13. Februar 2018, 15:25 Uhr


powershell commands

possible access rights

 The Access Rights parameters are as below:

    ReadItems:  The user has the right to read items within the specified folder.
    CreateItems   The user has the right to create items within the specified folder.
    EditOwnedItems   The user has the right to edit the items that the user owns in the specified folder.
    DeleteOwnedItems   The user has the right to delete items that the user owns in the specified folder.
    EditAllItems   The user has the right to edit all items in the specified folder.
    DeleteAllItems   The user has the right to delete all items in the specified folder.
    CreateSubfolders   The user has the right to create subfolders in the specified folder.
    FolderOwner   The user is the owner of the specified folder. The user has the right to view and move the folder and create subfolders. The user can’t read items, edit items, delete items, or create items.
    FolderContact   The user is the contact for the specified public folder.
    FolderVisible   The user can view the specified folder, but can’t read or edit items within the specified public folder.

The Roles with which we can provide the access rights are as below:

    None   FolderVisible
    Owner   CreateItems, ReadItems, CreateSubfolders, FolderOwner, FolderContact, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
    PublishingEditor   CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
    Editor   CreateItems, ReadItems, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
    PublishingAuthor   CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, DeleteOwnedItems
    Author   CreateItems, ReadItems, FolderVisible, EditOwnedItems, DeleteOwnedItems
    NonEditingAuthor   CreateItems, ReadItems, FolderVisible
    Reviewer   ReadItems, FolderVisible
    Contributor   CreateItems, FolderVisible


The following roles apply specifically to calendar folders:

    AvailabilityOnly   View only availability data
    LimitedDetails   View availability data with subject and location

create mailbox

Create a new mailbox

New-Mailbox -Name 'prospect NL' -Alias '' -OrganizationalUnit ' Fleet Europe/Stuttgart/Rooms and Equipment' \
  -UserPrincipalName '' -SamAccountName '' -FirstName 'prospect' -Initials  -LastName 'NL' \
  -Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $false -Database 'Stuttgart Mailbox DB One'

create linked mailbox

New-Mailbox -Name 'Koroch, Ernst' -Alias 'ekoroch' -OrganizationalUnit ' Fleet Europe/Stuttgart/Users' -UserPrincipalName \
'' -SamAccountName 'ekoroch' -FirstName 'Ernst' -Initials  -LastName 'Koroch' -Database 'Stuttgart Mailbox DB One' \
-LinkedMasterAccount 'fleetservices\ekoroch' -LinkedDomainController 'dc03.fleetservices.intra' -LinkedCredential \

Repair Mailbox


New-MailboxRepairRequest -Mailbox <Emailaddress> -CorruptionType SearchFolder,AggregateCounts,ProvisionedFolder,FolderView [-DetectOnly]

add mailbox permissions

Add full access to mailbox '' for user 'DOMAIN\user':

Add-MailboxPermission -Identity -User DOMAIN\user -AccessRights Fullaccess -InheritanceType All

-AccessRights <right>
where <right> may be


disable auto-mapping of

-Automapping $false

remove mailbox permissions

remove-MailboxPermission -Identity -user domari\user -AccessRights Fullaccess -inheritance all

add/remove 'Send as' permissions

Add-ADPermission -Identity 'CN=Mahnwesen,OU=Users,OU=Stuttgart,OU=ARI Fleet Europe,DC=arifleet,DC=com' -User 'DOMARI\ntrgovcevic' -ExtendedRights 'Send-as'

You can grant the permissions by using Active Directory Users & Computers. Simply open the properties of the group, switch to the Security tab, add the mailbox user or group, and then tick the Send As box and apply the change. After making this change you may notice that it does not take effect for up to 2 hours. This is due to caching on the Exchange servers. Though you can speed up the change by restarting the Information Store that is obviously not going to be practical in most production environments, so you’ll often find that you just need to wait.

Remove-ADPermission -Identity 'CN=Mahnwesen,OU=Users,OU=Stuttgart,OU=ARI Fleet Europe,DC=arifleet,DC=com' -User 'DOMARI\ntrgovcevic' -ExtendedRights 'Send-as'

'Send as'/'SendOnBehalf' Distributiongroups

Set-DistributionGroup <DistributionGroupName> -GrantSendOnBehalfTo

and sendOnBehalf for Distributiongroups

SentItem Configuration

Set-MailboxSentItemsConfiguration <ALIAS> -SendAsItemsCopiedTo SenderAndFrom

add mailbox folder permissions

Add-MailboxFolderPermission -Identity\Calendar -user -AccessRights <see RIGHTS>

Set default-rights for ressource mailboxes (to show up subjects a.s.o.):

Set-MailboxFolderPermission meetingroom:\Calendar -User Default -AccessRights Reviewer

get mailbox permissions

get permissions of fhess on mailbox

Get-MailboxPermission -Identity -User "fhess"

get folder permissions

get-mailboxfolderpermission -identity fhess

get UPN of users

Get-MailboxFolderPermission "USER:\Kalender" | Foreach-Object { $_.User.ADRecipient.UserPrincipalName }

get full user details

Get-MailboxFolderPermission "USER:\Kalender" | Foreach-Object { $_.identity.adrecipient.identity }

set Sent-Folder for group mailboxes

Set-MailboxSentItemsConfiguration <alias> -SendAsItemsCopiedTo SenderAndFrom -SendOnBehalfOfItemsCopiedTo SenderAndFrom

enable autoreply / vacation message

set the message (optionally) and enable auto reply

$message = get-content message.txt
Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState enabled \
                                          -ExternalAudience <none/all/known> \
                                          -InternalMessage "$message" \
                                          -ExternalMessage "$message"

disable auto-reply / vacation message

disable auto reply

Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState disabled

Retention policies

create server side retention policies

Create Retention Policy Tag

New-RetentionPolicyTag "ARI STG - Delete all 180 days" -Type All -Comment "Deletes all items older 180 days" -RetentionEnabled $true \
-AgeLimitForRetention 180 -RetentionAction DeleteAndAllowRecovery

RetentionAction: MoveToFolder, MoveToDeletedItems, DeleteAndAllowRecovery, PermanentlyDelete, MoveToArchive

Create Retention Policy

New-RetentionPolicy "ARI STG - Delete ALL items older 180 days" -RetentionPolicyTagLinks "ARI STG - Delete all 180 days"

Activate policy by: Open Mailbox Properties --> Mailbox Settings --> Messaging Records Mgmt --> Apply Retention policy

get distribution group members

get-distributiongroupmember <group>

get users by filter and add to distributiongroup

Get-ADUser -SearchBase 'OU=Stuttgart,OU=UserAccounts,OU=Accounts,DC=<DOMAIN>,DC=<DOMAIN>,DC=<TLD>' -filter \
{ (mail -like '*<PATTERN>*' -and (employeeType -ne 'MGR') -and enabled -eq 'true') } | \
%{ Add-DistributionGroupMember -identity '<GROUP>' -member $_.UserPrincipalName }
Get-ADUser -SearchBase 'OU=Stuttgart,OU=UserAccounts,OU=Accounts,DC=<DOMAIN>,DC=<DOMAIN>,DC=<TLD>' -filter \
{ (mail -like '*<PATTERN>*' -and (employeeType -eq 'MGR') -and enabled -eq 'true') } | \
%{ Add-DistributionGroupMember -identity '<GROUP>' -member $_.UserPrincipalName }

Get Mailbox by ExchangeGuid/Mapi-session

get-mailbox -ResultSize unlimited | where {$_.ExchangeGuid -eq "265182e3-a31c-4a9f-e38e-687f5a7c2d6b"}


further logfiles can be found here:

C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\ProtocolLog

Track accross multiple servers


e.g. that to "get-messagetrackinglog":

get-transportserver | get-messagetrackinglog

message tracking

get-messagetrackinglog -Sender '' -Start "5/04/2015 5:00:00 AM" -End "5/15/2015 8:30:00 AM"
get-transportserver | get-messagetrackinglog -Sender '' \
                                             -Start "6/01/2015 5:00:00 AM" \
                                             -End "6/01/2015 10:30:00 AM" \
                                             -resultsize unlimited | ft -Wrap
-MessageSubject <String>
-Recipients <String[]>
-Start/-End (get-date).AddHours(-1).toString()
-ResultSize Unlimited

some more examples:

get-messagetrackinglog -Start "6/8/2015 4:42:00 AM" -End "6/9/2015 9:52:00 PM" | Select *,{$_.Recipients} | export-csv .\maillog.csv
Get-MessageTrackingLog -resultsize unlimited | \
where-object {$_.Recipients -like “*, *” -AND $_.EventId -eq “Send”} |ft -auto >>C:\External mails.txt
Get-MessageTrackingLog -resultsize unlimited | sort -property Timestamp

repair mailbox

New-MailboxRepairRequest -Mailbox -CorruptionType SearchFolder

-CorruptionType ProvisionedFolder,SearchFolder,AggregateCounts,Folderview
-Archive        Prueft Mailbox _und_ Archive
-DetectOnly     Prueft nur, keine Reparatur!

Ergebnisse der Prüfung werden im Anwendungs Event-Log des Servers protokolliert. Die Events tragen die folgenden Ereignis-IDs:


mit einem rechtsklick auf 'Application' laesst dich das eventlog nach diesen ID's filtern.

move mailbox between exchange-databases

Move Mailboxes between exchange >= 2010 servers
the output is piped into 'ft' (format table) to get complete output and not stripped it...

New-MoveRequest -Identity -TargetDatabase ‘Whatever Database-Name 001’ | ft -AutoSize -Wrap

create a batch

Get-Mailbox -Database "Stuttgart Mailbox DB One" | Where-Object { $_.alias -like "jira*" } | New-MoveRequest -TargetDatabase [...]


-BadItemLimit 0
-SuspendComment "Resume after 11:00 p.m. PST"
-BatchName "Some Name to identify the Batch-Moves"

get moverequest status:

Get-MoveRequestStatistics "sadg"

Get-MoveRequest | Get-MoveRequestStatistics

Get-MoveRequest | Get-MoveRequestStatistics | select DisplayName,alias,Status,TotalMailboxSize,PercentComplete| ft

get Mailbox sizes

Get-MailboxDatabase | Where-Object { $_.Name -like "STG*" } | Get-MailboxStatistics | sort -property TotalItemSize -desc \
| select DisplayName,ItemCount,TotalItemSize,TotalDeletedItemSize |ft

get database size

Get-MailboxDatabase -status | select ServerName,Name,DatabaseSize

Get-MailboxDatabase -status | Sort-Object DatabaseSize -Desc | select ServerName,Name,DatabaseSize

Get-MailboxDatabase -status | Where-Object { $ -like "STG*" } | Sort -property DatabaseSize -Desc | select ServerName,Name,DatabaseSize

Export Mailbox (Folder)

New-MailboxExportRequest -mailbox schaden \
-includefolders "****** UNFALLORDNER ab 1.3.2011/Storopack R+V (*.***@*******.com)  TK 150 \/ keine VK RA Schmid" \
-filepath "\\stgwpvinfEXC01\g$\Storopack R+V (*.***@*******.com)  TK 150_keine VK RA Schmid.pst"
  1. be sure to mask e.g. '/' characters in foldernames with '\'
  2. leave out -includefolders to export the entire mailbox
    1. add a '.../*' to -includefolders to include subfolders

set thumbnail-image

from an exchange server

Import-RecipientDataProperty -Identity dSchlenzig -Picture -FileData \
([Byte[]]$(Get-Content -path ".\thumb-DOMARI.jpg"  -Encoding Byte -ReadCount 0))

from an AD

$photo = [byte[]](Get-Content path of pic -Encoding byte)
Set-ADUser username -Replace @{thumbnailPhoto=$photo}


some stuff i used the GUI for

Relay Configuration


Server-Configuration --> Hub Transport --> Receive Connectors (Tab)
- Select a valuable connector which matches you needs or create a new.
- for me there was 'Relay internal' which was to allow anonymous connects from spec. hosts/nets --> Double-Click
- Switch to 'Network'-Tab --> Add IP or rage to lower box.

Create an anonymous Receive Connector

after you created an receive connector by GUI you will have to run:

Get-ReceiveConnector "STGWPVINFEXC02\Application_Relay_Intern" | \
Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"