Kaffeeundcode
Script Library
PowerShell 01.06.2026

Script Workspace

Sync OnPremGroups

Review the purpose, inspect the code, then test it safely in your own tenant.

120_Sync-OnPremGroups.ps1

<#
.SYNOPSIS
    Prüft Sync-Status von On-Premises Gruppen.
    
.DESCRIPTION
    Zeigt an, wann eine synchronisierte Gruppe zuletzt aktualisiert wurde.
    Erfordert die Berechtigung 'Group.Read.All'.

.NOTES
    File Name: 120_Sync-OnPremGroups.ps1
    Author: Mattia Cirillo
    Version: 1.0
#>

param (
    [string]$GroupName
)

Connect-MgGraph -Scopes "Group.Read.All"

$Group = Get-MgGroup -Filter "displayName eq '$GroupName'" -Property OnPremisesLastSyncDateTime, OnPremisesSyncEnabled
if ($Group.OnPremisesSyncEnabled) {
    Write-Host "Last Sync: $($Group.OnPremisesLastSyncDateTime)"
} else {
    Write-Host "Reine Cloud-Gruppe."
}