#
$User = “username@your.office365.domain”
$Alias = “sendingas@any.domain.supported.by.your.office365.configuration”
#
#
################################################################
# Connect Powershell session to Exchange Online
# This will open a “Windows PowerShell Credential Request” prompt.
# You must logon with your Office 365 administrator account.
#################################################################
#
# Allow execution of remote (signed) scripts from Exchange Online
Set-Executionpolicy RemoteSigned -Scope process -Force
# Prompt user for login name/password
$LiveCred = Get-Credential
# Connect to Exchange Online
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
# Load Powershell commands from Exchange Online
Import-PSSession $Session
#
#
################################################################
# Create distribution group and give permissions to appropriate user
################################################################
#
New-DistributionGroup $Alias -PrimarySMTPAddress $Alias -Members $User
Add-RecipientPermission $Alias -accessrights sendas -trustee $User -Confirm:$false
Set-DistributionGroup $Alias -RequireSenderAuthenticationEnabled $false -Confirm:$false
#
#
################################################################
# Close PowerShell Exchange Online session
#################################################################
#
Remove-PSSession $Session
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)