orchestrator-powershell
orchestrator-powershell copied to clipboard
Add-UiPath Robot Error machine already Taken
I am adding a UiPath Robots using powershell, but it is giving me an error that the machine name is already taken. Is there a way to create UiPath Robots using the scripts where it in this case picks the already created machine?
Error:
powershell : Add-UiPathRobot : The operation returned an error: 1001: The machine name ROBOT01 is already taken
I used below command:
Add-UiPathRobot -Name $robotName -Username $username -MachineName $machineName -Password $password -Type $robotLicenseType -LicenseKey $licenseKey
The way it worked for me was to add the LicenseKey from the Machine I was adding the robot to. However even that is not straightforward, as you can get the licenseKey only if you Get the machine by Id:
$existingMachine = Get-UiPathMachine -Name $robot.MachineName
$existingMachine = Get-UiPathMachine -Id $existingMachine.Id
Add-UiPathRobot -Name $robot.Name -MachineName $robot.MachineName -Username $robot.Username -Type $robot.Type -HostingType $robot.HostingType -Description $robot.Description -CredentialType "Default" -LicenseKey $existingMachine.LicenseKey > $null
Thank you @sorincalin - I didn't pick up on that as the the errors are very generic and Get-Help is lacking in description and examples.
Is there a reason not to return the LicenseKey
when requesting by Name rather than Id
?
Seems silly to have to do it twice or not be able to pipe the i/o
(Get-UiPathMachine -Id ((Get-UiPathMachine -Name $machine).Id)).LicenseKey