|
| 1 | +--- |
| 2 | +title: Set employeeLeaveDateTime |
| 3 | +description: Explains how to manually set employeeLeaveDateTime. |
| 4 | +author: owinfreyATL |
| 5 | +ms.author: owinfrey |
| 6 | +ms.service: active-directory |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 09/07/2022 |
| 9 | +ms.custom: template-how-to |
| 10 | +--- |
| 11 | + |
| 12 | +# Set employeeLeaveDateTime |
| 13 | + |
| 14 | +This article describes how to manually set the employeeLeaveDateTime attribute for a user. This attribute can be set as a trigger for leaver workflows created using Lifecycle Workflows. |
| 15 | + |
| 16 | +## Required permission and roles |
| 17 | + |
| 18 | +To set the employeeLeaveDateTime attribute, you must make sure the correct delegated roles and application permissions are set. They are as follows: |
| 19 | + |
| 20 | +### Delegated |
| 21 | + |
| 22 | +In delegated scenarios, the signed-in user needs the Global Administrator role to update the employeeLeaveDateTime attribute. One of the following delegated permissions is also required: |
| 23 | +- User-LifeCycleInfo.ReadWrite.All |
| 24 | +- Directory.AccessAsUser.All |
| 25 | + |
| 26 | +### Application |
| 27 | + |
| 28 | +Updating the employeeLeaveDateTime requires the User-LifeCycleInfo.ReadWrite.All application permission. |
| 29 | + |
| 30 | +>[!NOTE] |
| 31 | +> The User-LifeCycleInfo.ReadWrite.All permissions is currently hidden and cannot be configured in Graph Explorer or the API permission blade of app registrations. |
| 32 | +
|
| 33 | +## Set employeeLeaveDateTime via PowerShell |
| 34 | +To set the employeeLeaveDateTime for a user using PowerShell enter the following information: |
| 35 | + |
| 36 | + ```powershell |
| 37 | + Connect-MgGraph -Scopes "User-LifeCycleInfo.ReadWrite.All" |
| 38 | + Select-MgProfile -Name "beta" |
| 39 | +
|
| 40 | + $UserId = "<Object ID of the user>" |
| 41 | + $employeeLeaveDateTime = "<Leave date>" |
| 42 | + |
| 43 | + $Body = '{"employeeLeaveDateTime": "' + $employeeLeaveDateTime + '"}' |
| 44 | + Update-MgUser -UserId $UserId -BodyParameter $Body |
| 45 | +
|
| 46 | + $User = Get-MgUser -UserId $UserId -Property employeeLeaveDateTime |
| 47 | + $User.AdditionalProperties |
| 48 | + ``` |
| 49 | + |
| 50 | + This script is an example of a user who will leave on September 30, 2022 at 23:59. |
| 51 | + |
| 52 | + ```powershell |
| 53 | + Connect-MgGraph -Scopes "User-LifeCycleInfo.ReadWrite.All" |
| 54 | + Select-MgProfile -Name "beta" |
| 55 | +
|
| 56 | + $UserId = "528492ea-779a-4b59-b9a3-b3773ef6da6d" |
| 57 | + $employeeLeaveDateTime = "2022-09-30T23:59:59Z" |
| 58 | + |
| 59 | + $Body = '{"employeeLeaveDateTime": "' + $employeeLeaveDateTime + '"}' |
| 60 | + Update-MgUser -UserId $UserId -BodyParameter $Body |
| 61 | +
|
| 62 | + $User = Get-MgUser -UserId $UserId -Property employeeLeaveDateTime |
| 63 | + $User.AdditionalProperties |
| 64 | +``` |
| 65 | + |
| 66 | + |
| 67 | +## Next steps |
| 68 | + |
| 69 | +- [How to synchronize attributes for Lifecycle workflows](how-to-lifecycle-workflow-sync-attributes.md) |
| 70 | +- [Lifecycle Workflows templates](lifecycle-workflow-templates.md) |
0 commit comments