Skip to content

Commit 7fb03bd

Browse files
authored
Merge pull request #1 from AlexFilipin/patch-6
Minor updates
2 parents 257d37c + 9272259 commit 7fb03bd

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

articles/active-directory/governance/set-employee-leave-date-time.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Set employeeLeaveDateTime for leaver workflows
3-
description: Explains how to manually set employeeLeaveDateTime for leaver workflows using PowerShell.
2+
title: Set employeeLeaveDateTime
3+
description: Explains how to manually set employeeLeaveDateTime.
44
author: owinfreyATL
55
ms.author: owinfrey
66
ms.service: active-directory
@@ -9,34 +9,50 @@ ms.date: 09/07/2022
99
ms.custom: template-how-to
1010
---
1111

12+
# Set employeeLeaveDateTime
13+
## Required permission and roles
14+
### Delegated
15+
In delegated scenarios the signed-in user needs the Global Administrator role to update the employeeLeaveDateTime attribute. In addition one of the following delegated permissions is required:
16+
- User-LifeCycleInfo.ReadWrite.All
17+
- Directory.AccessAsUser.All
1218

19+
### Application
20+
Updating the employeeLeaveDateTime requires the User-LifeCycleInfo.ReadWrite.All application permission.
1321

14-
# Set employeeLeaveDateTime for leaver workflows
15-
16-
When creating leaver workflows, it's required to set the date and time for when a user leaves. This parameter, employeeLeaveDateTime, is used to trigger the leaver workflow to run. Unlike other parameters, which can be synchronized using HR inbound Provisioning, Azure AD Connect sync, or Azure AD Connect Cloud sync, you must currently manually set the employeeLeaveDateTime for each user you want to process a leaver workflow for.
22+
>[!NOTE]
23+
> The User-LifeCycleInfo.ReadWrite.All permissions is currently hidden and cannot be configured in Graph Explorer or the API permssion blade of app registrations.
1724
25+
# Set employeeLeaveDateTime via PowerShell
1826
To set the employeeLeaveDateTime for a user using PowerShell enter the following information:
1927

20-
```powershell
21-
Connect-MgGraph -Scopes "User.ReadWrite.All","User-LifeCycleInfo.ReadWrite.All"
22-
28+
```powershell
29+
Connect-MgGraph -Scopes "User-LifeCycleInfo.ReadWrite.All"
2330
Select-MgProfile -Name "beta"
2431
25-
$URI = "https://graph.microsoft.com/beta/users/528492ea-779a-4b59-b9a3-b3773ef6da6d"
26-
$Body = '{"employeeLeaveDateTime": "<Leave date>"}'
27-
Invoke-MgGraphRequest -Method PATCH -Uri $URI -Body $Body
32+
$UserId = "<Object ID of the user>"
33+
$employeeLeaveDateTime = "<Leave date>"
34+
35+
$Body = '{"employeeLeaveDateTime": "' + $employeeLeaveDateTime + '"}'
36+
Update-MgUser -UserId $UserId -BodyParameter $Body
37+
38+
$User = Get-MgUser -UserId $UserId -Property employeeLeaveDateTime
39+
$User.AdditionalProperties
2840
```
2941

3042
This is an example of a user who will leave on September 30, 2022 at 23:59.
3143

3244
```powershell
33-
Connect-MgGraph -Scopes "User.ReadWrite.All","User-LifeCycleInfo.ReadWrite.All"
34-
45+
Connect-MgGraph -Scopes "User-LifeCycleInfo.ReadWrite.All"
3546
Select-MgProfile -Name "beta"
3647
37-
$URI = "https://graph.microsoft.com/beta/users/528492ea-779a-4b59-b9a3-b3773ef6da6d"
38-
$Body = '{"employeeHireDate": "<Hire date>","employeeLeaveDateTime": "2022-09-30T23:59:59Z"}'
39-
Invoke-MgGraphRequest -Method PATCH -Uri $URI -Body $Body
48+
$UserId = "528492ea-779a-4b59-b9a3-b3773ef6da6d"
49+
$employeeLeaveDateTime = "2022-09-30T23:59:59Z"
50+
51+
$Body = '{"employeeLeaveDateTime": "' + $employeeLeaveDateTime + '"}'
52+
Update-MgUser -UserId $UserId -BodyParameter $Body
53+
54+
$User = Get-MgUser -UserId $UserId -Property employeeLeaveDateTime
55+
$User.AdditionalProperties
4056
```
4157

4258

0 commit comments

Comments
 (0)