Powershell issue - interactive vs UiPath

Afternoon folks

I have a simple Powershell script to extract information from Active Directory, which, before we upgraded our project from Windows Legacy to Windows was working without issue, and continues to work if we roll back to the original issue.

The script (saved as a .ps1 file) is as below
Get-ADUser -Filter * -properties EmailAddress -SearchBase $Container | Select-Object Name, SamAccountName, EmailAddress, DistinguishedName, Enabled | Export-Csv $FilePath -NoTypeInformation

with the parameters $Container and $FilePath either being included in the ps1 file or passed as parameters.

If I run the script in a Powershell window, it runs without issue

If I run it from the Invoke Powershell Activity, it fails and returns an error
Invoke Power Shell: File C:\powershell\GetADUsersSubset1.ps1 cannot be loaded because running scripts is disabled on this system.

The execution policies are set as follows
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Bypass

Any assistance appreciate please

Many thanks

@gary.cobden

Please try running this in power shell by opening it as an admin …or run power shell in admin

Set-ExecutionPolicy RemoteSigned

Cheers

Hi @Anil_G

The script runs fine if executed in Powershell directly; its running within UiPath that is the issue - thats when I get the error!

@gary.cobden

Agreed…This is for checking if this remote setting would let UiPath run the power shell script

cheers

Following consultation with Support, turns out there is a bug in the Powershell Activity that needs to be fixed

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