Get-MgmtGraphContactMemberOf
MgmtGraph: Audits group membership for an organizational contact
#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Identity.DirectoryManagement
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, Position = 0)]
[string]$Identity
)
Process {
try {
$groups = Get-MgContactMemberOf -OrgContactId $Identity -All -ErrorAction Stop
$results = foreach ($g in $groups) {
[PSCustomObject]@{
DisplayName = $g.AdditionalProperties.displayName
Type = $g.AdditionalProperties.'@odata.type'.Replace('#microsoft.graph.', '')
Id = $g.Id
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
}
Write-Output ($results | Sort-Object DisplayName)
}
catch {
throw
}
}Specifies the ID of the organizational contact to audit.