Posts tagged with "M365"

PowerShell Script for Azure AD Synchronization Management

This PowerShell script performs the following actions:

  1. It retrieves the Windows identity and security principal of the current user account.
  2. It then retrieves the security principal for the Administrator role.
  3. It checks if the current user is running as an administrator. If the user is not running as an administrator, the script relaunches itself as an elevated process.
  4. If the user is running as an administrator, the script displays a menu with three options: “Delta Sync”, “Full Sync”, and “Exit”. The user is prompted to select an option by entering the corresponding number.
  5. Based on the user’s selection, the script runs the appropriate command using the Start-ADSyncSyncCycle cmdlet with either the Delta or Initial policy type. If the user selects “Exit”, the script exits.
  6. Finally, the script displays a message indicating that it is running and to check the “miisclient” to confirm. It then pauses for 10 seconds using the Start-Sleep cmdlet.
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator

if (-not $myWindowsPrincipal.IsInRole($adminRole)) {
    $newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell"
    $newProcess.Arguments = $myInvocation.MyCommand.Definition
    $newProcess.Verb = "runas"
    [System.Diagnostics.Process]::Start($newProcess)
    exit
}

Write-Host '1) Delta Sync (Recommended, unless told to do a full sync)'
Write-Host '2) Full Sync'
Write-Host '3) Exit'

$selected_menu_item = Read-Host 'Which number would you like to run (1 or 2)? (Enter Number and Press Enter)'

switch ($selected_menu_item) {
    1 { Start-ADSyncSyncCycle -PolicyType Delta }
    2 { Start-ADSyncSyncCycle -PolicyType Initial }
    3 { Write-Host 'Exit'; exit }
    default { Write-Host 'Incorrect Input' -ForegroundColor Red }
}

Write-Host 'Running Now.... Check miisclient to confirm'
Start-Sleep -s 10

Published: February 9, 2023 | Last Modified: May 13, 2025

Microsoft 365 Email Security Management Guide

Block Unwanted Emails

Objective: Prevent sending or receiving emails from specific external email addresses or domains.

Action: Navigate to the Tenant Allow/Block List in the Microsoft Security Center. Configure the settings to block specific email addresses or domains. For direct access, use this link: Tenant Allow/Block List.

Review Past Week of Sign-In History

Objective: Review sign-in history to identify any unusual user activity.

Action: Access the Azure portal’s sign-in history section. Specify the user of interest and examine their sign-in locations and activities. Access the portal here: Azure Sign-In History.

Published: February 7, 2023 | Last Modified: May 13, 2025

Managing Exchange Calendars

A collection of PowerShell scripts using ExchangeOnlineManagement module to manage calendar permissions in Exchange Online, including bulk operations for granting, modifying, and viewing access rights across multiple mailboxes.

Published: September 16, 2021 | Last Modified: May 13, 2025