We forgot something when building the purview retentionlabel add command.
https://pnp.github.io/cli-microsoft365/cmd/purview/retentionlabel/retentionlabel-add/
If you configure the --retentionTrigger option to dateOfEvent, you would need to configure a retention Event Type Id.
This is not really clear in the documentation currently, how to do it. That's why we forgot it.
We need an extra optional option set that is only required when dateOfEvent is used:
Options
| Option |
Description |
--eventTypeId [eventTypeId] |
The Id of the event type that is used to in case of an event-based label. Specify when using retentionTrigger with the value dateOfEvent. Specify either eventTypeId or eventTypeName, but not both. |
--eventTypeName [eventTypeName] |
The display name of the event type that is used to in case of an event-based label. Specify when using retentionTrigger with the value dateOfEvent. Specify either eventTypeId or eventTypeName, but not both. |
Examples
Create an event-based retention label that retains documents as records and deletes them one year after a Contract Expiry event date.
m365 purview retentionlabel add --displayName 'some label' --behaviorDuringRetentionPeriod retain --actionAfterRetentionPeriod delete --retentionDuration 365 --retentionTrigger dateOfEvent --eventTypeName "Contract Expiry"
Remarks
The following should be added in the request object when posting to purview. This binds the event type to the label.
"[email protected]" : "https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes/<retentionEventTypeId>"
When using eventTypeName we need to get the ID from Purview, just like it's done in the purview retentioneventtype list command. We cannot use a $filter parameter on the retentionEventType graph endpoint.
Let's filter client side. Typically, organisations won't have large lists of event-types, so this is OK, performance wise.
We forgot something when building the
purview retentionlabel addcommand.https://pnp.github.io/cli-microsoft365/cmd/purview/retentionlabel/retentionlabel-add/
If you configure the
--retentionTriggeroption todateOfEvent, you would need to configure a retention Event Type Id.This is not really clear in the documentation currently, how to do it. That's why we forgot it.
We need an extra optional option set that is only required when
dateOfEventis used:Options
--eventTypeId [eventTypeId]retentionTriggerwith the valuedateOfEvent. Specify eithereventTypeIdoreventTypeName, but not both.--eventTypeName [eventTypeName]retentionTriggerwith the valuedateOfEvent. Specify eithereventTypeIdoreventTypeName, but not both.Examples
Create an event-based retention label that retains documents as records and deletes them one year after a Contract Expiry event date.
Remarks
The following should be added in the request object when posting to purview. This binds the event type to the label.
When using
eventTypeNamewe need to get the ID from Purview, just like it's done in the purview retentioneventtype list command. We cannot use a$filterparameter on the retentionEventType graph endpoint.Let's filter client side. Typically, organisations won't have large lists of event-types, so this is OK, performance wise.