Graph - EmployeeLeaveDateTime not possible to set

RobNow 0 Reputation points
2024-01-10T09:36:05.6066667+00:00
Hello,

We are trying to add the attribute "employeeLeaveDateTime" to a user via Graph.

We have followed the documentation from Microsoft (https://learn.microsoft.com/en-us/graph/tutorial-lifecycle-workflows-set-employeeleavedatetime?tabs=powershell):

Connect-MgGraph -Scopes "User.Read.All", "User-LifeCycleInfo.ReadWrite.All"
Select-MgProfile -Name "v1.0"

$UserId = "528492ea-779a-4b59-b9a3-b3773ef6da6d"
$employeeLeaveDateTime = "2022-09-30T23:59:59Z"
    
Update-MgUser -UserId $UserId -EmployeeLeaveDateTime $employeeLeaveDateTime
$User = Get-MgUser -UserId $UserId
$User.EmployeeLeaveDateTime


Unfortunately, the date is not set...
The Code "Select-MgProfile" is not working , maybe thats why we are having Problems?

We would be very happy about your support!

Screenshot 2024-01-10 100102.png
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,014 questions
{count} votes

3 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 41,941 Reputation points
    2024-01-11T02:30:54.64+00:00

    Hi @RobNow,

    This issue may be caused by you not installing or updating the 'Microsoft.Graph.Authentication' module. This module contains Select-MgProfile and other commands related to connecting to the Microsoft Graph PowerShell SDK.

    To resolve this issue, you can try the following steps:

    • Open PowerShell and run the Install-Module Microsoft.Graph.Authentication command to install or update the 'Microsoft.Graph.Authentication' module.
    • Restart PowerShell and run the Import-Module Microsoft.Graph.Authentication command to import the module.

    Get this module: User's image

    Configure the employeeLeaveDateTime property for a user: User's image

    Hope this helps. If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

  2. RobNow 0 Reputation points
    2024-01-10T09:54:06.2233333+00:00

    Screenshot 2024-01-10 100102

    Here a Screenshot of my try to set the Attribute

    0 comments No comments

  3. Rui Paz 0 Reputation points
    2024-04-05T08:48:30.65+00:00

    Hi,

    For Get-MgUser to return the values you need to request them! like this:

    $User = Get-MgUser -UserID $UserId -Property UserPrincipalName, EmployeeLeaveDateTime
    $User.EmployeeLeaveDateTime
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.