Zum Inhalt
Kaffeeundcode
Skriptbibliothek
PowerShell 06.10.2026

PowerShell

Auto Tenant Doc Generator

Auto-Tenant-Doc-Generator.ps1

<#
.SYNOPSIS
    Auto-Tenant-Doc-Generator - Exports full Intune configuration to a structured Markdown Wiki.

.DESCRIPTION
    <!-- library-status:start -->
    Prüfstatus: Ungeprüft
    Aus dem bestehenden GitHub-Bestand übernommen; fachliche und Tenant-Abnahme ausstehend.

    <!-- library-status:end -->

    Iterates through Configuration Profiles, Compliance Policies, and App Assignments
    to create a comprehensive documentation file in Markdown format.
#>

[CmdletBinding()]
param (
    [Parameter(Mandatory=$false)]
    [string]$OutputPath = "Tenant-Documentation.md"
)

process {
    $Doc = New-Object System.Collections.Generic.List[string]
    $Date = Get-Date -Format "yyyy-MM-dd HH:mm"

    $Doc.Add("# 📑 Intune Tenant Configuration Report")
    $Doc.Add("Generated on: $Date")
    $Doc.Add("---")

    # 1. Configuration Profiles Section
    $Doc.Add("## 🛠️ Configuration Profiles")
    try {
        $Profiles = Get-MgDeviceManagementConfigurationPolicy
        if ($Profiles) {
            $Doc.Add("| Profile Name | ID | Description |")
            $Doc.Add("| :--- | :--- | :--- |")
            foreach ($P in $Profiles) {
                $Doc.Add("| $($P.DisplayName) | $($P.Id) | $($P.Description) |")
            }
        } else { $Doc.Add("_No profiles found._") }
    } catch { $Doc.Add("❌ Error fetching profiles: $($_.Exception.Message)") }

    $Doc.Add("`n")

    # 2. Compliance Policies
    $Doc.Add("## 🛡️ Compliance Policies")
    try {
        $Compliance = Get-MgDeviceManagementCompliancePolicy
        if ($Compliance) {
            $Doc.Add("| Policy Name | ID | Description |")
            $Doc.Add("| :--- | :--- | :--- |")
            foreach ($C in $Compliance) {
                $Doc.Add("| $($C.DisplayName) | $($C.Id) | $($C.Description) |")
            }
        } else { $Doc.Add("_No compliance policies found._") }
    } catch { $Doc.Add("❌ Error fetching compliance policies: $($_.Exception.Message)") }

    # 3. App Assignments
    $Doc.Add("`n## 📦 Application Assignments")
    try {
        $Apps = Get-MgDeviceAppManagementManagedApp
        if ($Apps) {
            $Doc.Add("| App Name | ID | Publisher |")
            $Doc.Add("| :--- | :--- | :--- |")
            foreach ($A in $Apps) {
                $Doc.Add("| $($A.DisplayName) | $($A.Id) | $($A.Publisher) |")
            }
        } else { $Doc.Add("_No apps found._") }
    } catch { $Doc.Add("❌ Error fetching apps: $($_.Exception.Message)") }

    $Doc.Add("`n---")
    $Doc.Add("Footer: Generated by Bruno AI for kaffeeundcode.com")

    $Doc | Out-File -FilePath $OutputPath -Encoding utf8
    Write-Host "[SUCCESS] Documentation exported to: $OutputPath" -ForegroundColor Green
}