kkpatel
(Kamal)
April 14, 2022, 10:06am
1
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
kkpatel
(Kamal)
April 14, 2022, 10:11am
3
[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
kkpatel
(Kamal)
April 14, 2022, 10:12am
4
$fileName is the input argument I am using in the code.
1 Like
Try removing the return statement please…
Thanks
#nK
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 :
1 Like
kkpatel
(Kamal)
April 14, 2022, 11:32am
9
Correct. I am also getting it now.
2 Likes
system
(system)
Closed
April 17, 2022, 11:33am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.