Updating EmployeeHireDate in Powershell

Copper Contributor

I'm surprised there are no posts about this yet. We are trying to update our employee's date of hires according to our HR team's records. There looks to be an option to update the value through Update-AzureADUser (https://learn.microsoft.com/en-us/powershell/module/az.resources/update-azaduser?view=azps-10.0.0)


At first, I thought it was an issue with the date string "mm/dd/yyyy" in the script. I am now grabbing the date of hire from a spreadsheet in text format and pushing it through Get-Date to get a variable $DateofHire to pass into the Update-AzureADUser command as a [datetime]. I'm receiving the following error:

Update-AzADUser : A parameter cannot be found that matches parameter name 'EmployeeHireDate'.

Full error Message:


Update-AzADUser : A parameter cannot be found that matches parameter name 'EmployeeHireDate'.
At line:1 char:45
+ Update-AzADUser -UPN 'email address removed for privacy reasons' -EmployeeHireDate $HireDa ...
+                                             ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Update-AzADUser], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADUserCommand


My update command is as follows "$_." refers to the CSV file object being imported. Even though the parameter "EmployeHireDate" is listed in the MS Article, it seems to not want to accept it. We do not use that GraphAPI stuff, and our AD is fully Azure, we have no on-prem AD.



$DateofHire = Get-Date $_.HireDate -UFormat %m/%d/%Y
        Update-AzADUser -UPN $_.UserPrincipalName -EmployeeHireDate $DateofHire



2 Replies



Firstly, you are using Graph whether you realise it or not, which you can see for yourself when running the relevant Az.Resources commandlets in conjunction with the -Debug parameter:




Setting that aside, the error you're getting is quite straightforward: the version of the module you have installed does not contain a parameter named EmployeeHireDate.


I was a few versions behind as I don't use the Az modules for much, but even on Az.Resources module versino 6.2.0, the EmployeeHireDate parameter exists. Having just updated to the current 6.7.0, I can confirm it still exists.


So, one option is for you to ensure that:


  1. You have a recent version of the module (along with the aligned version of Az.Accounts - in fact you would do well to ensure they're all version-aligned) that supports EmployeeHireDate;
  2. That when you run your script, it's referencing that most-recent version and not a previous version, which can happen for various reasons if you have multiple versions installed - including across platforms (i.e. x86 and x64 versions are both installed.)


You can check which version has loaded by trying to run your script, and if that fails for the "unknown parameter" reason, running Get-Module to see which version of Az.Accounts and Az.Resources have loaded.


A better option is to forget about Update-AzADUser entirely as it doesn't not support newer (or as many) user attributes, including another one you might be interested in: EmployeeLeaveDateTime.


If you are working with HR and already playing around with EmployeeHireDate, it might be prudent to also look into populating EmployeeLeaveDateTime, which is supported under the newer Microsoft.Graph.Users module, as can be seen in the following Update-MgUser article:



So, that's two options for resolving your issue. I'd recommend the second as that's the direction Microsoft is investing in (as evidenced by the fact that Az.Resources doesn't support newer attributes) but whichever one you choose, it'd still be prudent (or required in the first scenario) to ensure you have updates the Az modules and that the updated versions are indeed being loaded.




Hi @pck7101 


I've tested this with a CloudOnly account


$HireDate = (Get-Date).AddDays(-10)
Update-AzADUser -UPN email address removed for privacy reasons -EmployeeHireDate $HireDate
Get-AzADUser -UPN email address removed for privacy reasons -Select EmployeeHireDate | fl *hire*



With the Microsoft.Graph PowerShell you can also set the employeeLeaveDateTime 


Connect-MgGraph -Scopes user.readwrite.all
$HireDate = (Get-Date).AddDays(-30)
$LeaveDate = Get-Date
Update-MgUser -UserId email address removed for privacy reasons -EmployeeHireDate $HireDate -employeeLeaveDateTime $LeaveDate
Get-MgUser -UserId email address removed for privacy reasons -Property EmployeeHireDate, employeeLeaveDateTime | fl *emp*