Yasha_S
(Yasha Sharma)
May 14, 2024, 5:18pm
1
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.
1 Like
@Yasha_S ,
Why not using Invoke Power Shell Activity? It provides output arguments built in.
Thanks,
Ashok
1 Like
Also create the logs and exceptions, @ashokkarale solution works for you
Yasha_S
(Yasha Sharma)
May 15, 2024, 5:44pm
4
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
Yasha_S
(Yasha Sharma)
May 17, 2024, 3:52pm
6
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
1 Like