New-MgmtGraphGroupLifecyclePolicy
MgmtGraph: Creates a new group lifecycle policy
#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Groups
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, Position = 0)]
[string]$AlternateNotificationEmails,
[int]$GroupLifetimeInDays = 180,
[ValidateSet('All', 'Selected', 'None')]
[string]$ManagedGroupType = 'None'
)
Process {
try {
$params = @{
'AlternateNotificationEmails' = $AlternateNotificationEmails
'GroupLifetimeInDays' = $GroupLifetimeInDays
'ManagedGroupTypes' = $ManagedGroupType
'Confirm' = $false
'ErrorAction' = 'Stop'
}
$policy = New-MgGroupLifecyclePolicy @params
$result = [PSCustomObject]@{
PolicyId = $policy.Id
GroupLifetimeInDays = $policy.GroupLifetimeInDays
ManagedGroupTypes = $policy.ManagedGroupTypes
AlternateNotificationEmails = $policy.AlternateNotificationEmails
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $result
}
catch {
throw
}
}Semicolon-separated list of email addresses to send expiration notifications to for groups without active owners.
The number of days a group can exist before it must be renewed. Default is 180 days.
The scope of groups to which this policy applies. Default is 'None'. Supported values: All, Selected, None.