No output of Powershell script with parameters, I am Able to run the script in powershell with good result but through Uipath it there is no Output

My Powershell script is using some parameters and a command. I can get the correct result when I run it manually but when I run it through UiPath Invoke-PS it gives no error and no output.

STEPS
Create a admin session through UiPath
Run script with parameters
create an output file.

Commands
Param(
[Parameter(Mandatory=$true)] [string]$OUTPUTPATH,
[Parameter(Mandatory=$true)] [string]$XXX,
[Parameter(Mandatory=$true)] [string]$RESULT
)
cd Workingdirectory
.\script.ps1 -OutputPath $OUTPUTPATH | out-file -Filepath $RESULT -append

I get a blank result file.

image
image

1 Like

@Yasha_S,

Why not using Invoke Power Shell Activity? It provides output arguments built in.

Thanks,
Ashok :slight_smile:

1 Like

Also create the logs and exceptions, @ashokkarale solution works for you

Already Using the script through Invoke PS.

@Yasha_S,

Earlier screenshot was showing you are using Start Process.

What’s the output you get in PSOutput?

Thanks,
Ashok :slight_smile:

The Start process is to login by Admin as the script cannot run through a user login so the session needs to be admin session.

PSOutput:
System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSCustomObject]

Also, it does not accept Object core activity, has to be PSCustom object.Otherwise i get errors.

@Yasha_S, You can convert it to string using
String.Join("",outputVariable)

For running it in admin I think Start Process is the solution as of now.

Thanks,
Ashok :slight_smile:

1 Like