Invoke powershell error Connect-AzAccount

Hi,

I’m suffering and error i can’t understand. I have a process that generate a file and one this has been generated the idea is upload the file to Azure Data lake gen2.

I have prepared a powershell script that perform all those actions. If i run the powershell script manually on the server, works perfect but if when i run the script in using the Uipath task is showing that error:

The term ‘Connect-AzAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

RemoteException wrapping System.Management.Automation.CommandNotFoundException: The term ‘Connect-AzAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I’m preatty confident that the Connect-AzAccount is installe din the machine because as i said , running the script manually is ok.
Here you can see the options i have in the invoke

I hope you can help me with this

Hi.

Probably, it’s 32bit/64bit matter. So, can you try to use StartProcess activity to call the following, istead of Invoke PowerShell activity?

C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe

Or it might be better to create bat file to call ps script using the above exe.

Regards,

Hi ,

Is happening the same , I’ve installed the modules in the x86 powershell and the error is the same.
Also if I use the .bat and run the script works fine but if i us the Start Process with the the .bat is failing giving this error:

Also if i run the Connect-AzAccount in the powershell console (32 or 64bits) works fine and is showing a popup to login. So for sure the module is installed on the server.

Thanks for your help

Do you know in which folder you have installed the module Az.Accounts? If yes, you could try to specify the full path. E.g. to import the Defender module with full path:

import-module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Defender