Unable to filter and get just the return variable from a .ps1 script execution

36 views Asked by At
$scriptPath = "${{ github.action_path }}\get_details.ps1"
$ServerName = "remoteserver777"

$returnArray = & "$scriptPath" -mypass ${{ inputs.mypass }} -myuser ${{ inputs.myuser }} -ServerName $ServerName

Write-Host "Print return data- $returnArray" 

The .ps1 returns cmdb_ci_linux_server,2,8.9,Test,10.130.68.70 which is what i want; but when i print $returnArray it has $ServerName remoteserver777 that was passed as parameter to the .ps1 script.

Current output:

Print return data- remoteserver777 cmdb_ci_linux_server,2,8.9,Test,10.130.68.75

Desired Output:

Print return data- cmdb_ci_linux_server,2,8.9,Test,10.130.68.75

I then tried to only filter Select-Object -ExpandProperty Output and get the output returned by .ps1 script return $returnValues by trying the below:

Invoke-Expression -Command & 'D:\Git-Runners\s1_work_actions\newfeature\getdetails\get_details.ps1' -mypass *** -myuser svc_AMS_AppReliabilityEng -ServerName remoteserver777 | Select-Object -ExpandProperty Output
Select-Object : Property "Output" cannot be found.

Kindly suggest.

0

There are 0 answers