I am writing powershell script to create a tenant in orchestrator. In order to do that I am trying to fetch authentication token using below script, but it does not seem to work.
@Remus_Rusanu I am able to connect now in different powershell session. Actually if in same powershell script I am loging in to my azure account and fetching username and password from the key-vault, then assigning them to variables and then trying to connect to orchestrator it gives above error.
I am not much into powershell so please let me know if doing this is correct or not as in my scenario I need to fetch orchestrator credentials from azure key vault.
For sake of understanding the scenario below is stripped down version of the actual script that is trying to access azure key vault first then connecting to UiPath orchestrator.
$ErrorActionPreference = “Stop”
sign in
Write-Host “Logging in…”;
Login-AzureRmAccount;
Connect-AzAccount
accept subsciptionID
if($subscriptionId -eq ‘’) {
$subscriptionId = Read-Host -Prompt ‘Please enter your subscription ID’
}
if($vaultName -eq ‘’) {
$vaultName = Read-Host -Prompt ‘Please enter key-vault name’
}
if($secretNameHost -eq ‘’) {
$secretNameHost = Read-Host -Prompt ‘Please enter secret name used to fetch the password that connects to orchestrator.’
}
Typically the problem occurs because another library loads a conflicting module into the PoSh process. The usual suspect is Newtonsoft.Json.dll, and and old version is loaded by the old Azure Automation library (see Page Not Found). Switching to the modern Az module solves the problem (see Introducing the Azure Az PowerShell module | Microsoft Learn)
If it shows a different version, it means there is another auto-load module (or a cmdlet you have in your profile, or a cmdlet that you run before…) that loaded an old version.
This sort of issues is difficult to diagnose remotely. Even if you find out that is not Newtonsoft.Json, it could be another assembly that has a similar problem.