You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A PowerShell script to set Send As permissions for Office365 users and groups
4
+
5
+
## Usage
6
+
7
+
### Prerequisites
8
+
9
+
- The script uses the `ExchangeOnlineManagement` PowerShell module, which requires a minimum PowerShell version of 7.0.3 to be installed. Powershell 7 is installed by default on any Windows 10 or newer PC released after March 2020. The `ExchangeOnlineManagement` module will install automatically as part of the script if not already present.
10
+
- The PowerShell execution policy must be set to run unsigned scripts. While running the script may automatically prompt to change the execution policy, it can be changed in PowerShell by running the command `Set-ExecutionPolicy Unrestricted`.
11
+
- Execution policy can be reset after running the script using `Set-ExecutionPolicy RemoteSigned`
12
+
13
+
### Running the Script
14
+
15
+
- The script can be run by right clicking the `setSendAs.ps1` file and choose “Run with PowerShell,” but I would advise running the script within a PowerShell window to monitor the output.
16
+
- Steps to run it in an open PowerShell window:
17
+
- Hit the Windows key and the R key together to open a `Run` dialog box. Type “powershell” in the box and hit the Enter key.
18
+
- If execution policy hasn't been set to `Unrestricted` yet, type `Set-ExecutionPolicy Unrestricted` and hit the Enter key.
19
+
- Drag and drop the script file into the window to paste the path to the script in the shell. Hit the Enter key.
20
+
- It will ask for the admin user email to authenticate to Exchange Online, the user email getting SendAs Trustee permissions, whether setting an individual user `U` or all users in a Office365 group `G`, and the user email or Office 365 group to assign the permission to. Fill in the prompts as desired to set the parameters.
21
+
- A Microsoft sign-in window will appear to authenticate with Exchange Online once the parameters are provided.
22
+
23
+
## License
24
+
25
+
This project is licensed under the terms of the MIT license.
Connect to the specified Exchange Online environment and set the SendAs permission for the specified user or Office 365 group. Will install the EXO management module if it does not exist
3
+
#>
4
+
5
+
FunctionConnect-EXO {
6
+
<#
7
+
.SYNOPSIS
8
+
Connects to EXO when no connection exists. Checks for EXO v3 module
9
+
#>
10
+
param(
11
+
[Parameter(
12
+
Mandatory=$true
13
+
)]
14
+
[string]$adminUPN
15
+
)
16
+
17
+
process {
18
+
# Check if EXO is installed and connect if no connection exists
19
+
if ($null-eq (Get-Module-ListAvailable -Name ExchangeOnlineManagement))
20
+
{
21
+
Write-Host"Exchange Online PowerShell v3 module is requied, do you want to install it?"-ForegroundColor Yellow
22
+
23
+
$install=Read-HostDo you want to install module? [Y] Yes [N] No
0 commit comments