Office 365 – Connecting through PowerShell
Install these two!
PowerShell Module:
◾Microsoft Online Services Module for Windows PowerShell 32-bit
◾Microsoft Online Services Module for Windows PowerShell 64-bit
Microsoft Online Services Sign-In Assistant 7.0 Beta:
◾Microsoft Online Services Sign-In Assistant 32-bit
◾Microsoft Online Services Sign-In Assistant 64-bit
Microsoft Online / Azure / Office365 Powershell
Description | Command |
Import MSOL Module This is not required if you are using the Azure powershell module… |
Import-Module MSOnline |
Get Connected | Connect-MSOLService |
Allowing scripts to run | Set-ExecutionPolicy RemoteSigned |
Set User Password | Set-MsolUserPassword –UserPrincipalName "name@domain.com" –NewPassword "9+characters!" -ForceChangePassword $False |
Find out whether a password is set to never expire | Get-MSOLUser -UserPrincipalName | Select PasswordNeverExpires Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires |
Set a password to never expire | Set-MsolUser -UserPrincipalName "user@domain.com" -PasswordNeverExpires $true |
List Licensed Users | Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } |
This connection method is required for the commands below to run!!
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Convert a mailbox to a user mailbox | Set-Mailbox "mailbox display name" -Type:Regular |
Convert a mailbox to a shared mailbox, long version | Get-Mailbox <primary SMTP address> | Set-Mailbox –ProhibitSendReceiveQuota 5GB –ProhibitSendQuota 4.75GB –IssueWarningQuota 4.5GB –type shared |
Find what mailboxes a user can access | Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User "Joe Bloggs" | Format-Table Identity, AccessRights, Deny |
Grant permissions to a mailbox (Joannav can send as Test) |
$Mailbox = "test@itprodev.onmicrosoft.com" |