Forum Discussion
pck7101
Jun 16, 2023Copper Contributor
Updating EmployeeHireDate in Powershell
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 Updat...
LainRobertson
Jun 17, 2023Silver Contributor
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:
- 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;
- 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.
Cheers,
Lain