Invoke Powershell Activity giving ADAL Error for API call

Client has written powershell script to call an API. And I’m trying to integrate this from uipath by calling Invoke Powershell script but I get the error as below:

“Invoke Power Shell: The ‘Get-ADALToken’ command was found in the module ‘ADAL.PS’, but the module could not be loaded. For more information, run ‘Import-Module ADAL.PS’.”

So I included Import-Module -Name ADAL.PS -RequiredVersion 3.19.8.1 but this gives below error :
“Invoke Power Shell: PowerShell command errors:
The current processor architecture is: X86. The module ‘C:\Program Files (x86)\WindowsPowerShell\Modules\ADAL.PS\3.19.8.1\ADAL.PS.psd1’ requires the following architecture: Amd64.
The specified module ‘ADAL.PS’ with version ‘3.19.8.1’ was not loaded because no valid module file was found in any module directory.”

When I run the same powershell script manually from Powershell ISE or CMD it works fine.
The powershell uses Azure AD for authentication. I have also tried invoking the ps script as batch file but still the same error it throws.

Also I have installed the required version module in both 32bit and 64bit. Can anyone help here?

1 Like

@Lakshmi_Holla Can you maybe show us a Screenshot of the Properties panel of the Invoke Powershell Activity ?

Please find properties panel and also the entire sequence.

Hi @Lakshmi_Holla

Hope this helps !!!
Happy Automation !!!

1 Like

Thank you. I have used the same method ,i.e saving script in text editor and running. All give the same issue. The issue is related to the way uipath activity calls the powershell script I feel.

Uipath is reading the inputs and when it tries to make authentication call to Azure , it needs certain module called ADAL.ps and somehow uipath is not able to load/import it. This module is present in the system already.

When you run the PowerShell script manually, you are using the 64-bit version of PowerShell, which might explain why it’s working. When you use Invoke Power Shell activity, UiPath is using the 32-bit version of PowerShell.

If it’s just a matter of version (as the error message indicates), the workaround is to use the 64-bit version of PowerShell instead. First you need to figure out where the 64-bit version is located and then run it with your PS file as the parameter. E.g. you could use the following PS script with the Invoke Power Shell activity:

"Set-ExecutionPolicy Unrestricted -Scope CurrentUser
$PathToPowerShell64bit = Get-ChildItem -Path $Env:Windir\WinSxS | Where-Object {$_.FullName -match 'amd64_microsoft-windows-powershell-exe'}
$PowerShell64bitExe = Get-ChildItem -Path $PathToPowerShell64bit.FullName -Filter PowerShell.exe | Select-Object -ExpandProperty FullName
& $PowerShell64bitExe -file 'C:\Test\Hello64.ps1'"

image

Thank you for this information. I’ll try this out and let you know how it comes out.

Thank you @ptrobot . This worked for me :slight_smile:

1 Like

You are welcome! Happy to hear that it worked. :grinning:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.