#Getting extra fields in the payload

5 messages · Page 1 of 1 (latest)

fallow hollow
#

Hi,
I have a powershell script. In that script I'm trying to create a payload but in that payload I'm getting extra fields like PSPath, PSDrive, and PSBlah PSBlah stuff. But I don't need those PS things. How can I get rid of them?

#

    $outputFilename = "$outputDir/output_$roleName.txt"

    ....
    ....

    $outputFileContent = Get-Content -Path $outputFilename -Raw
    
    # Prepare Add Auth to Role API Payload
    $authPayload = @{
        roleName = $roleName
        apiCond = @{ "" = "" }
        index = 0
        authParamData = @(
            @{ key = "cookie"; showHeader = $true; value = "\${x1.response.body.token}"; where = "HEADER" },
            @{ key = "authorization"; showHeader = $true; value = "\${x1.response.body.aktoOutput.authTokenHeader}"; where = "HEADER" }
        )
        authAutomationType = "LOGIN_REQUEST"
        reqData = @(@{
            tokenFetchCommand = "Object.entries(cookieMap).join('; ')"
            content = $outputFileContent
            type = "RECORDED_FLOW"
        })
        recordedLoginFlowInput = @{
            content = $outputFileContent
            tokenFetchCommand = "Object.entries(cookieMap).join('; ')"
            outputFilePath = $null
            errorFilePath = $null
        }
    } | ConvertTo-Json -Depth 6
#

I'm getting those PS fields only in two fields. One is reqData and another one is recordedLoginFlowInput

#

Please let me know if you need anything else to help me out.

pliant elk
#

It's Get-Content that's adding those. You might try: ```ps
$outputFileContent = Get-Content -Path $outputFilename -Raw | ForEach-Object ToString

Otherwise use the .NET methods to read the file content. Bit of a daft one that I'm afraid.