-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSet-CW365Permission.ps1
24 lines (22 loc) · 1.07 KB
/
Set-CW365Permission.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<#
The purpose of this script is to make permissions changes so connectwise
may send as the new O365 account. Failure to make this change on the
account will cause emails sent from the user to fail silently.
#>
#below gets the office 365 credentials
$O365Credential = Get-Credential
#below takes input for email alias
$O365Alias = Read-Host -Prompt "Email alias of the account"
#below sets up the remote session
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://outlook.office365.com/powershell-liveid/ `
-Credential $O365Credential -Authentication Basic -AllowRedirection
#below suppresses warnings
$WarningPreference = "SilentlyContinue"
#below starts the remote session
Import-PSSession $O365Session | Out-Null
#below configured the access rights
Add-MailboxPermission -Identity $O365Alias -User CWAdmin -AccessRights FullAccess `
-InheritanceType All -Confirm:$false -WarningAction SilentlyContinue | Out-Null
#below closes the remote session
Remove-PSSession -ComputerName "outlook.office365.com"