Home » Cloud » Daily IT helpdesk office365/Azure powershell commands for managing office365

Daily IT helpdesk office365/Azure powershell commands for managing office365

Below is what is needed to connect to office365 using powershell – you will need to make sure that you have the correct module installed which can be installed using the command below

Install-Module MSOnline

$credential = Get-Credential email addresss

$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://outlook.office365.com/powershell-liveid/” -Credential $credential -Authentication “Basic” -AllowRedirection

Import-PSSession $exchangeSession -DisableNameChecking


$lyncSession = New-CsOnlineSession -Credential $credential

Now that you are connected to office365, you can run to commands to get the data

How to set the the mailbox size in office365

Get-Mailbox username or email  | Select *quota

Set-Mailbox -Identity username or email -ProhibitSendQuota 75GB -ProhibitSendReceiveQuota 80GB -IssueWarningQuota 73GB

How to set the mailbox size

Get-Mailbox -ResultSize unlimited | Set-Mailbox -ProhibitSendReceiveQuota 100GB

How to get the all the unlicensed users in Office 365

Get-MsolUser -All -UnlicensedUsersOnly

How to get the list of AzureAd cloud only groups

Get-AzureADGroup -All $true | where-Object {$_.OnPremisesSecurityIdentifier -eq $null}

How to create a Azuread security group

New-AzureADGroup -Description “xxxx” -DisplayName “xxxxx” -MailEnabled $false -SecurityEnabled $true -MailNickName “XX_XX”

How to get all the rules associated with the Office 365 mailbox and export to CSV

Get-InboxRule -Mailbox test@test.com | Export-csv c:\Rules_mailbox.csv -NoClobber

How to do a mailbox search using the command line 

# has to be less than a week old user “start-historicalsearch” for more than a week
get-messagetrace SenderAddress “test@test.com” -StartDate “1/24/2018” -EndDate “1/26/2018” | Export-Csv C:\output.csv

Start-HistoricalSearch -SenderAddress “email” -StartDate “1/24/2018” -EndDate “1/26/2018” -ReportTitle name_email-Trace -ReportType MessageTrace | Export-Csv c:

How to get the list of all O365/AD users  using powershell

Get-MsolDevice -all | select-object -Property Enabled, DeviceId, DisplayName, DeviceTrustType, ApproximateLastLogonTimestamp | export-csv devicelist-summary.csv

How to get the DKIM configuration details


How to get the Azure tenant details using powershell


Leave a Reply

Your email address will not be published. Required fields are marked *