Skript Beschreibung
Zusammenfassung: Stale-Group-Purge - Cleans up empty or orphaned groups in Entra ID.
Prüfstatus: Ungeprüft
Aus dem bestehenden GitHub-Bestand übernommen; fachliche und Tenant-Abnahme ausstehend.
Scans for groups that have zero members or no assigned owners,
reducing clutter and improving security posture.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[switch]$WhatIf
)
process {
Write-Host "[INFO] Scanning for stale groups..." -ForegroundColor Cyan
$Groups = Get-MgGroup -All
$StaleGroups = @()
foreach ($Group in $Groups) {
# Check member count
$Members = Get-MgGroupMember -GroupId $Group