Kaffeeundcode
Script Library
PowerShell 01.06.2026

Script Workspace

Find OrphanedGroups

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

116_Find-OrphanedGroups.ps1

<#
.SYNOPSIS
    Findet Gruppen ohne Besitzer (Orphaned Groups).
    
.DESCRIPTION
    Durchsucht alle Gruppen und prüft, ob die Owner-Liste leer ist.
    Erfordert die Berechtigung 'Group.Read.All'.

.NOTES
    File Name: 116_Find-OrphanedGroups.ps1
    Author: Mattia Cirillo
    Version: 1.0
#>

param()

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

$Groups = Get-MgGroup -All
foreach ($G in $Groups) {
    $Owners = Get-MgGroupOwner -GroupId $G.Id -ErrorAction SilentlyContinue
    if (!$Owners) {
        Write-Host "Gruppe ohne Owner: $($G.DisplayName)" -ForegroundColor Yellow
    }
}