How to get output from a powershell activity?

Hi All

I am using Powershell activity to convert a file from .txt to .json. The files are getting converted properly.

But I want to print some output like the output file path. I am not able to do so.

In the TypeArgument property if I select String and output as the collection of strings then its giving null value in the collection. Similarly I tried for FIleInfo argument but it is also throwing some error.

So what should be the Argument ?

@supermanPunch @Palaniyappan

1 Like

Hey @kkpatel

Kindly show us the script to suggest please…

Thanks
#nK

[CmdletBinding()]

Gets file content that contains :: delimiter and remove NUL chararcters

$content = (Get-Content $FilePath -Encoding Ascii | where {$_ -match ‘::’}) -replace ‘\0’

Replace :: with =

$content = $content.Replace(“::”,“=”)

Converts content to a Hash (key and value pairs) table

$Props = ConvertFrom-StringData -StringData ( $content | Out-String)

Get filename without extension

$fileName = $FilePath.Substring(0, $FilePath.LastIndexOf(‘.’))

Convert to JSON format

$Props | ConvertTo-Json | Out-File “$fileName.json”
return “$fileName.json”

1 Like

$fileName is the input argument I am using in the code.

1 Like

Try removing the return statement please…

Thanks
#nK

No Its not helping.

1 Like

Hey @kkpatel

Hope you are choosing the right type argument,

Thanks
#nK

Hi @kkpatel ,

I am able to get the Output using a return provided the TypeArgument is a String :

image

1 Like

Correct. I am also getting it now.

2 Likes

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