Reference:

https://docs.microsoft.com/en-us/office365/enterprise/powershell/getting-started-with-office-365-powershell

https://technet.microsoft.com/library/jj984289(v=exchg.160).aspx

PowerShell connection to exchange online:

PS C:\WINDOWS\system32> Set-ExecutionPolicy -scope currentUser RemoteSigned

PS C:\WINDOWS\system32> $UserCredential = Get-Credential     <== do not use an account with Azure MFA enabled

Note: if you are using Azure MFA to connect to Exchange online, follow this article: https://technet.microsoft.com/en-us/library/mt775114(v=exchg.160).aspx

PS C:\WINDOWS\system32> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

In case of problem due to Message: “The WinRM client cannot process the request. Basic authentication is currently disabled in the client configuration”

PS E:\–DEV WORK–> winrm get winrm/config/client
Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = false [Source=”GPO”]
Auth
Basic = false [Source=”GPO”]
Digest = false [Source=”GPO”]
Kerberos = true [Source=”GPO”]
Negotiate = true [Source=”GPO”]
Certificate = true
CredSSP = true [Source=”GPO”]
DefaultPorts
HTTP = 5985
HTTPS = 5986
TrustedHosts

 

Import-PSSession $Session

ModuleType Version    Name                                ExportedCommands
———- ——-    —-                                —————-
Script     1.0        tmp_0gtrs5dm.juw                    {Add-AvailabilityAddressSpace, Add-DistributionGroupMember, Add-MailboxFolderPermission, Add-MailboxLocation…}

PS C:\WINDOWS\system32> Get-Mailbox | Get-MailboxStatistics

Note: https://technet.microsoft.com/library/13843002-56ca-4b75-81c5-84386522b01b.aspx

PS C:\WINDOWS\system32> Get-Mailbox | Where {$_.emailaddresses -like “smtp:*@mydomain.net”}

For Office 365 groups:

Note: https://thoughtsofanidlemind.com/2015/05/07/new-management-cmdlets-for-office-365-groups/

PS C:\WINDOWS\system32> Get-Recipient –RecipientTypeDetails “GroupMailbox”

PS C:\WINDOWS\system32> get-unifiedgroup “All Guest users”

After your work, dont forget to stop the remote session:

Remove-PSSession $Session

Advertisements