Whenever I need to run some powershell commands on an Office 365 Exchange server, I always end up scouring the internet looking for commands and walkthroughs. Below Is an excerpt from a list a coworker of mine put together with a few extra commands that I added in myself. Enjoy!
First, you want to install the “Windows Azure Active Directory Module for Windows PowerShell” from http://technet.microsoft.com/en-us/library/jj151815.aspx. You can install this anywhere.
Using this tool you can connect to Office 365 with the following
commands
$cred = Get-Credential (log in using your Office 365 username and password when prompted)
$session = New-PSSession -ConfigurationName Microsoft.Exchange
-ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic
-AllowRedirection
Import-PSSession $session
And then from here you can run any Exchange PowerShell command you like.
If you are using DirSync at the client site You can check the status using:
Connect-MsolService
(Get-MsolCompanyInformation).DirectorySynchronizationEnabled
You can change the status (enable or disable DirSync)
Set-MsolDirSyncEnabled –EnableDirSync $false (or $true to enable)
You can give an account full access to all current mailboxes for migration purposes
Get-Mailbox -ResultSize Unlimited | Add-MailboxPermission -AccessRights FullAccess
-Automapping $false -User insertnamehere
If you have delete users from Office 365 portal and need to remove them from Delete users
List Deleted users
Get-MsolUser -ReturnDeletedUsers
Delete deleted users
Get-MsolUser –ReturnDeletedUsers | foreach { Remove-MsolUser -ObjectId $_.ObjectId
-RemoveFromRecycleBin -Force }
Disable Password Complexity
Get-MsolGroupMember -groupObjectid <id> | Set-MsolUser -StrongPasswordRequired $False
Run the following command to set users’ passwords to never to expire.
Get-MsolGroupMember -groupObjectid <id> | Set-MsolUser -PasswordNeverExpires $true
First, you want to install the “Windows Azure Active Directory Module for Windows PowerShell” from http://technet.microsoft.com/en-us/library/jj151815.aspx. You can install this anywhere.
Using this tool you can connect to Office 365 with the following
commands
$cred = Get-Credential (log in using your Office 365 username and password when prompted)
$session = New-PSSession -ConfigurationName Microsoft.Exchange
-ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic
-AllowRedirection
Import-PSSession $session
And then from here you can run any Exchange PowerShell command you like.
If you are using DirSync at the client site You can check the status using:
Connect-MsolService
(Get-MsolCompanyInformation).DirectorySynchronizationEnabled
You can change the status (enable or disable DirSync)
Set-MsolDirSyncEnabled –EnableDirSync $false (or $true to enable)
You can give an account full access to all current mailboxes for migration purposes
Get-Mailbox -ResultSize Unlimited | Add-MailboxPermission -AccessRights FullAccess
-Automapping $false -User insertnamehere
If you have delete users from Office 365 portal and need to remove them from Delete users
List Deleted users
Get-MsolUser -ReturnDeletedUsers
Delete deleted users
Get-MsolUser –ReturnDeletedUsers | foreach { Remove-MsolUser -ObjectId $_.ObjectId
-RemoveFromRecycleBin -Force }
Disable Password Complexity
Get-MsolGroupMember -groupObjectid <id> | Set-MsolUser -StrongPasswordRequired $False
Run the following command to set users’ passwords to never to expire.
Get-MsolGroupMember -groupObjectid <id> | Set-MsolUser -PasswordNeverExpires $true