Skip to content

Get-MSTUserPolicyPackage-Html

Teams: HTML report of user's assigned policy package

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$Identity
)

Process {
    try {
        [hashtable]$getArgs = @{'ErrorAction' = 'Stop'; 'Identity' = $Identity}

        $packages = Get-CsUserPolicyPackage @getArgs | Select-Object Name, Description, PackageType, RecommendationType
        $result = @()
        foreach ($pkg in $packages) {
            $result += [PSCustomObject]@{
                Name               = $pkg.Name
                Description        = $pkg.Description
                PackageType        = $pkg.PackageType
                RecommendationType = $pkg.RecommendationType
                Policies           = if ($null -ne $pkg.Policies) { ($pkg.Policies.Keys -join '; ') } else { '' }
            }
        }

        if ($result.Count -eq 0) {
            Write-Output "No policy package assigned"
            return
        }

        Write-Output ($result | ConvertTo-Html -Fragment)
    }
    catch { throw }
}

The user that will get their assigned policy package

An interactive directory of PowerShell scripts.