Exchange

Enable modern authentication in Exchange Online:
Set-OrganizationConfig -OAuth2ClientProfileEnabled $true
Disable modern authentication in Exchange Online:
Set-OrganizationConfig -OAuth2ClientProfileEnabled $false
To verify that the change was successful, run this command:
Get-OrganizationConfig | Format-Table -Auto Name,OAuth*
$Mailboxes = Get-Mailbox -id  Deborah_Polen-Pitman
$Results = foreach( $Mailbox in $Mailboxes ){
    $Folders = $MailBox |
        Get-MailboxFolderStatistics |
        Measure-Object |
        Select-Object -ExpandProperty Count

    New-Object -TypeName PSCustomObject -Property @{
        Username    = $Mailbox.Alias
        FolderCount = $Folders
        }
    }

$Results |
    Select-Object -Property Username, FolderCount
function check_queue
 {
 $QueueCount = get-transportserver | get-queue | measure-object MessageCount -max

# Set the limit here 
if ($QueueCount.Maximum -gt 20)
 {
 send_email $QueueCount.Maximum
 exit
 }

# How often to check
 start-sleep -s 300
 check_queue
 }
 
function send_email
 {param ($queue_size)
 
$emailFrom = "from@who.com"
 $emailTo = "to@who.com"
 $subject = "Exchange queue at $queue_size"
 $body = "Mail queues are high, last seen at $queue_size"
 $smtpServer = "smtp.mydomain.net"
 $smtp = new-object Net.Mail.SmtpClient($smtpServer)
 $smtp.Send($emailFrom, $emailTo, $subject, $body)
 
}
 
check_queue
Use the start-job command.
start-job ./CheckQueue.ps1
># Setting the parameters 
Param (
[Parameter(Mandatory=$true)]
[string]$Username
)


# Import the tools to work with AD.
Import-Module ActiveDirectory

# Get Primary Proxy Address.
$user = Get-ADUser -Identity $username  -Properties proxyAddresses
$primarySMTPAddress = ""
foreach ($address in $user.proxyAddresses)
{
    if (($address.Length -gt 5) -and ($address.SubString(0,5) -ceq 'SMTP:'))
    {
        $primarySMTPAddress = $address.SubString(5)
        break
    }
}
$primarySMTPAddress