Updating Employee Hire Date with PowerShell.

Stefan Diedericks 125 Reputation points
2023-06-05T07:25:42.9333333+00:00

Is the a script a can use to update EmployeeHireDate with PowerShell while referencing a csv list for the list of employees?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,299 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,499 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 103.4K Reputation points MVP
    2023-06-05T12:55:24.7733333+00:00

    Hi @Stefan Diedericks ,

    this should be possible using the Update-AzADUser cmdlet of the AzureAD PowerShell module.

    Read the content of the CSV file first (UPN or ObjectID is required) and use a foreach loop for every line in the CSV file.

    A sample could look like this (not tested!):

    $csvFile = "users.csv" # assuming there is a column named UPN
    $hireDate = (Get-Date).Date # Get date of today
    Import-Csv -Path $csvFile | ForEach-Object {
        Update-AzADUser -UPNOrObjectId $_.UPN -EmployeeHireDate $hireDate
    }
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten