Issue Set-UnityUser change user password
Andryv opened this issue · comments
Hi,
I've an issue in using the module Set-UnityUser for change users password.
When I try to run the command "Get-UnityUser -Name $user | Set-UnityUser -oldPassword $oldPassword -newPassword $newPassword" windows prompt to me a confirmation but after that nothing happen.
Command output:
id : user
name : user
role : @{id=administrator}
All commands:
Connect-Unity -Server $UnityIP
Get-UnityUser -Name $user | Set-UnityUser -oldPassword $oldPassword -newPassword $newPassword
Disconnect-Unity
- Powershell version: 5.1.17134.858
- System Unity 400 software version 4.5.1.0.5.001
Thanks.
Hey! So I took a look at the code and resolved this locally for my use case.
Set-UnityUser Module has two issues:
1 - The module references an incorrect variable
This is what currently exists.
# oldPassword parameter If ($password -and $oldPassword) { $body["oldPassword"] = "$($oldPassword)" $body["password"] = "$($newPassword)" }
This is what it should be updated to:
# oldPassword parameter If ($newPassword-and $oldPassword) { $body["oldPassword"] = "$($oldPassword)" $body["password"] = "$($newPassword)" }
2 - Also, I was unable to pipe in the user as you did above, instead I had to reference the ID specifically.
Set-UnityUser -ID ((Get-UnityUser -name $username).ID) -oldPassword $oldPassword -newPassword $newPassword
Hope this helps!!