Search code examples
azurepowershellazure-data-lake

Writing output of String manipulation to Azure Data lake Store Item


When I try to write an output of a String manipulation of Get-AzureRmDataLakeStoreItemContent output to a variable and try to pass it in a variable to New-AzureRmDataLakeStoreItem i am getting error "New-AzureRmDataLakeStoreItem : Invalid content passed in. Only byte[] and string content is supported."

I verified that the output of Get-command is an Object but I dont understand why i am not able to pass it. I am not sure whether I need some more transformation like a Hashtable to store into an output in Azure Data lake store. Or is it an Encoding problem. Please help in deciphering this error

Here is the code and i am also attaching a screenshot of the error. Original input

1|2|3|a,b,
3|4|5|d,h,

Output of String manipulation

1|2|3|a,b
3|4|5|d,h

$data=((Get-AzureRmDataLakeStoreItemContent -Account $accountName -Path $myrootdir/V_FQP_ITC_11_VEHICLE/test.csv).ToString() -split("`r")).Trim() | ForEach-Object {$_.TrimEnd(",")}
New-AzureRmDataLakeStoreItem  -Account $accountName -path $myrootdir/test_output.txt -Value $data 

Error


Solution

  • Seems you need to add a "" of $data, it works on my side.

    New-AzureRmDataLakeStoreItem  -Account "joydatalake1" -path "/sss/test_output.txt" -Value "$data"
    

    enter image description here