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
Connect-msolservice
$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
get-DkimSigningConfig
How to get the Azure tenant details using powershell
Get-AzureADTenantDetail
How to check the status of the Modern Auth in office 365
Get-OrganizationConfig | FT OAuth*
How to find an alternate email that is tied to primary mailbox
Get-MsolUser -All | ? {$_.AlternateEmailAddresses -eq “user@domain.com“}
Get-Mailbox -ResultSize unlimited | ? {$_.ForwardingAddress -match “user@domain.com“} | select name,PrimarySmtpAddress,Forward*
Get-Mailbox -ResultSize unlimited | ? {$_.ForwardingSmtpAddress -match “user@domain.com“} | select name,PrimarySmtpAddress,Forward*
How to get devices in Azure AD with registered owners and export to CSV
Get-MsolDevice -ReturnRegisteredOwners -All | Export-Csv -Path c:\temp\intune_devices.csv -NoTypeInformation
How to get the count of members in Azure AD group
(Get-AzureADGroup -ALL 1 -Filter “DisplayName eq ‘group name*'” | Get-AzureADGroupMember -ALL 1).count