Created
February 7, 2018 16:29
-
-
Save royashbrook/9f0d008f07a5e7d05c56c1dfe074b1d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add/Remove Email Access For Another Mailbox: | |
# First get a session to work in, unless you have the tools installed | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange ` | |
-ConnectionUri http://mailserver/PowerShell/ ` | |
-Authentication Kerberos | |
Import-PSSession $Session | |
# setup users | |
$a = 'user@email.com' #who's mailbox is it? | |
$b = 'admin@email.com' #who are we giving access to? | |
#Add | |
$p0 = Get-MailboxPermission $a # permissions before | |
Add-MailboxPermission $a -User $b -AccessRights FullAccess -InheritanceType All | |
$p1 = Get-MailboxPermission $a # permissions after | |
"Before:" | |
$p0 | |
"After:" | |
$p1 | |
#Remove | |
$p2 = Get-MailboxPermission $a # permissions before | |
Remove-MailboxPermission $a -User $b -AccessRights FullAccess -InheritanceType All -Confirm:$false | |
$p3 = Get-MailboxPermission $a # permissions after | |
"Before:" | |
$p2 | |
"After:" | |
$p3 | |
# Search for an email address on some kind of object: | |
Get-Recipient -Filter {EmailAddresses -like "*partialemail*"} | |
#Get Distribution Group Members: | |
#assumes the following query returns a dg object | |
$dg = (Get-Recipient -Filter {EmailAddresses -like "*partialemail*"}) | |
Get-DistributionGroupMember -Identity $dg.Name | |
# Add Email Address to DG or User: | |
Set-Mailbox "User One" -EmailAddresses @{add="user.one@email.com"} | |
Set-DistributionGroup "dg name" -emailaddresses @{Add='test@email.com','test1@email.com','test2@email.com'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment