Much simpler may be to use AVMA activation.
https://learn.microsoft.com/en-us/windows-server/get-started/automatic-vm-activation
https://4sysops.com/archives/change-a-product-key-remotely-with-powershell/
--please don't forget to upvote
and Accept as answer
if the reply is helpful--