Forum Discussion
TomWechsler
Jan 17, 2021MVP
A few PowerShell (in Exchange Online) impressions summarized!
Hi Microsoft 365 and Exchange Online Friends,
In this article I have summarized a few tasks that I used on a project. This is certainly not an exhaustive summary when it comes to working with Exchange Online, I just wanted to summarize a few points.
I used the Visual Studio Code Editor for this configuration. But you are also very welcome to use the PowerShell ISE, just as you wish. Please start with the following steps to begin the "journey" (the Hashtags are comments):
#The first two lines have nothing to do with the configuration, but make some space below in the black part of the VSCode
Set-Location C:\Temp
Clear-Host
#To be able to install the exchange online module
Set-ExecutionPolicy RemoteSigned
#Install the exchange online management module
Install-Module -Name ExchangeOnlineManagement -Verbose -Force
#Update the module (if necessary)
Update-Module -Name ExchangeOnlineManagement -Verbose -Force
#Connect to exchange online
Connect-ExchangeOnline -UserPrincipalName admin365@yourdomain.onmicrosoft.com
#Is an archive already in use?
Get-Mailbox | Where-Object {$_.ArchiveDatabase -ne $null}
Get-Mailbox | Where-Object {$_.ArchiveDatabase -ne $null} | Format-Table name, archivedatabase, archivename, archivequota, archivewarningquota -AutoSize
#Run this command to enable the archive mailbox for a single user
Enable-Mailbox -Identity "peter@contosotom.ch" -Archive
#Run this command to enable the archive mailbox for all users in your organization
Get-Mailbox -Filter {ArchiveStatus -Eq "None" -AND RecipientTypeDetails -eq "UserMailbox"} | Enable-Mailbox -Archive
#Note: When you turn on an archive, a retention policy should also be configured
#Run this command to disable the archive mailbox for a single user
Disable-Mailbox -Identity "peter@contosotom.ch" -Archive
#Run this command to disable the archive mailbox for all users in your organization
Get-Mailbox -Filter {ArchiveStatus -Eq "Active" -AND RecipientTypeDetails -eq "UserMailbox"} | Disable-Mailbox -Archive
#This example returns a summary list of all distribution groups that can be upgraded to Microsoft 365 Groups
Get-EligibleDistributionGroupForMigration -ResultSize unlimited
#This example creates device access rules that blocks access for Android
New-ActiveSyncDeviceAccessRule -Characteristic DeviceType -QueryString "Android" -AccessLevel Block
#To proof the rule has been created
Get-ActiveSyncDeviceAccessRule
#To remove the rule use
Remove-ActiveSyncDeviceAccessRule -Identity "Android (DeviceType)"
#To proof the rule has been removed
Get-ActiveSyncDeviceAccessRule
I am absolutely aware that this is nothing spectacular. I just wanted to share a few impressions with you.
I hope this article was useful. Best regards, Tom Wechsler
P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler
No RepliesBe the first to reply