Connect to 365
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService
Get-MsolUser
Get-MsolUser | select UserPrincipalName, ValidationStatus, IsLicensed, BlockCredential, StrongPasswordRequired, PasswordNeverExpires | ft
You may require below. I’m running Win10 64-bit and I needed below.
Microsoft Online Services Sign-in Assistant for IT Professionals RTW. http://go.microsoft.com/fwlink/p/?LinkId=286152 Windows Azure Active Directory Module for Windows PowerShell (64-bit version) http://go.microsoft.com/fwlink/p/?linkid=236297
Enable script (ExecutionPolicy)
Set-ExecutionPolicy Unrestricted or Set-ExecutionPolicy RemoteSigned
Set password never expires
Get-MsolUser -UserPrincipalName xxx@xxx.com.sg | fl Set-MsolUser -UserPrincipalName xxx@xxx.com.sg -PasswordNeverExpires $true
#Apply to all users Get-MsolUser | Set-MsolUser -PasswordNeverExpires $True
Set strong password false
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires, StrongPasswordRequired Get-MsolUser | Set-MsolUser -StrongPasswordRequired $false
Set user password
Set-MsolUserPassword –UserPrincipalName xxx@xxx.com.sg –NewPassword xxx -ForceChangePassword $False
Change Principal Name (to set password same as username)
Set-MsolUserPrincipalName -UserPrincipalName abc@xxx.com.sg -NewUserPrincipalName abcc@xxx.com.sg Set-MsolUserPassword –UserPrincipalName abcc@xxx.com.sg –NewPassword "abc" -ForceChangePassword $False Set-MsolUserPrincipalName -UserPrincipalName abcc@xxx.com.sg -NewUserPrincipalName abc@xxx.com.sg
Remove immutable id
Set-MsolUser -UserPrincipalName "xyz@xxx.com.sg" -ImmutableId $null
Mailbox size
Find out mailbox size for 1 user
Get-MailboxStatistics kim | fl DisplayName, TotalItemSize
Find out mailbox size for each user sorted in MB
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select DisplayName, @{name="TotalItemSize (MB)"; expression={[math]::Round(($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}, ItemCount | Sort "TotalItemSize (MB)"
Find out mailbox size for each user sorted in GB
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select DisplayName, @{name="TotalItemSize (GB)"; expression={[math]::Round(($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1GB),2)}}, ItemCount | Sort "TotalItemSize (GB)"
Find big items from each mailbox
Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -IncludeAnalysis -FolderScope All | Where-Object {$_.TopSubjectSize -gt 19MB} | Select-Object Identity, TopSubject, TopSubjectSize | Export-CSV -path "C:\report.csv" -notype
Get mailbox folder statistics
Get-MailboxFolderStatistics kim | select identity, itemsinfolder
Disable POP & IMAP
Get-CASMailbox Get-CASMailbox | select DisplayName, PopEnabled, ImapEnabled Get-CASMailbox | select DisplayName, PopEnabled, ImapEnabled, MAPIEnabled, OWAEnabled, ActiveSyncEnabled, EwsEnabled | ft
Disable POP & IMAP for all mailbox
Get-Mailbox | Set-CASMailbox –POPEnabled $False Get-Mailbox | Set-CASMailbox -ImapEnabled $false
Disable ActiveSync for a user
Get-Mailbox Kim | Set-CASMailbox -ActiveSyncEnabled $true #Check changes Get-CASMailbox -Identity Kim
Get/Set mailbox size limits
Get-Mailbox kim | select ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota Get-Mailbox | select Name, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota
Set mailbox size limits for a single user
Set-Mailbox kim -ProhibitSendQuota 19GB -ProhibitSendReceiveQuota 20GB -IssueWarningQuota 15GB
Set mailbox size for all
Get-Mailbox | Set-Mailbox -ProhibitSendQuota 49GB -ProhibitSendReceiveQuota 50GB -IssueWarningQuota 45GB
Purge deleted users
#Look for deleted users Get-MsolUser -ReturnDeletedUsers #Delete single user (Same as using GUI) Remove-MsolUser -UserPrinciplalName xxx@xxx.com.sg #Purge single deleted user Remove-MsolUser -RemoveFromRecycleBin -UserPrincipalName xxx@xxx.com.sg #Purge all deleted users Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force
Disable Clutter
Direct link to disable Clutter from end user running Office 365
https://outlook.office365.com/owa/#path=/options/clutter
Purge RecoverableItems
#Delete Search-Mailbox kim -SearchDumpsterOnly -DeleteContent -Force #Check after delete Get-MailboxFolderStatistics -Identity "Kim" -FolderScope RecoverableItems | Format-Table Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders -Auto
Adding admin account to Discovery Management is required.
Discovery Management requires roles: Legal Hold, Mailbox Import Export & Mailbox Search
Full step to purge
# Get Deleted item retention period Get-Mailbox kim | FL SingleItemRecoveryEnabled,RetainDeletedItemsFor # Get access setting Get-CASMailbox Kim | FL EwsEnabled,ActiveSyncEnabled,MAPIEnabled,OWAEnabled,ImapEnabled,PopEnabled # Check if any retention policies applied Get-Mailbox Kim | FL LitigationHoldEnabled,InPlaceHolds Get-OrganizationConfig | FL InPlaceHolds # Current size & total items in Recoverable Get-MailboxFolderStatistics Kim -FolderScope RecoverableItems | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders # Current size & total items in Recoverable (Archived) Get-MailboxFolderStatistics Kim -FolderScope RecoverableItems -Archive | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders # Disable mailbox Set-CASMailbox Kim -EwsEnabled $false -ActiveSyncEnabled $false -MAPIEnabled $false -OWAEnabled $false -ImapEnabled $false -PopEnabled $false # Set desired retention period (1 day or 30 days) Set-Mailbox Kim -RetainDeletedItemsFor 1 # Remove Litigation Hold Set-Mailbox Kim -LitigationHoldEnabled $false # Purge Search-Mailbox Kim -SearchQuery size>0 -SearchDumpsterOnly -DeleteContent # Verify that items were deleted Get-MailboxFolderStatistics Kim -FolderScope RecoverableItems | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders # Verify that items were deleted (in Archive) Get-MailboxFolderStatistics Kim -FolderScope RecoverableItems -Archive | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders
View your RecoverableItems in Mailbox & Archive
# Mailbox Get-MailboxFolderStatistics kim -FolderScope RecoverableItems | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders # Archive Get-MailboxFolderStatistics kim -FolderScope RecoverableItems -Archive | FL Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders # Purge Search-Mailbox kim -SearchQuery size>0 -SearchDumpsterOnly -DeleteContent
Increase DefaultPublicFolder size limit
#Get DefaultPublicFolder value Get-OrganizationConfig | fl *DefaultPublicFolder* #5GB Set-OrganizationConfig -DefaultPublicFolderProhibitPostQuota 5368709120 #10GB Set-OrganizationConfig -DefaultPublicFolderProhibitPostQuota 10737418240
Increase security by using SPF
Add DNS record
v=spf1 ip4:115.xxx.xx.xx ip4:202.xx.xx.xx ip4:xx.xx.xx.xx include:spf.protection.outlook.com -all
Specify IP address ranges using CIDR notation
v=spf1 ip4:202.168.0.1/26 include:spf.protection.outlook.com -all
Moving OST in Outlook 2010
Control Panel > Mail > E-mail Account settings > Exchange server account > Advanced tab > Disable Cached > Apply > Offline Folders File Settings > Disable Offline Use > Press OK on warning pops-up > Offline Folders File Settings > browse to new OST location > Enable Cache
Increase Outlook rules quota
Get-InboxRule -Mailbox kim Get-Mailbox -Identity kim | ft *rulesquota*, PrimarySmtpAddress Set-Mailbox -Identity kim -RulesQuota 256KB