0

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

  • HI Joy, The command writes the Literal value "System-Object" to the output file" PS C:\Users\> New-AzureRmDataLakeStoreItem -Account $accountName -path $myrootdir/test_1.csv -Value $data.ToString() /landing_zone/rd/vedoc/096/data/test_1.csv PS C:\Users\> Get-AzureRmDataLakeStoreItemContent -Account $accountName -Path $myrootdir/test_1.csv System.Object[] – Naveen Venugopal Nov 29 '18 at 06:57
  • See the update of my answer. – Joy Wang Nov 29 '18 at 07:02

1 Answers1

1

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

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
  • Thanks Joy Once again. That was a silly mistake from my side. Thanks for correcting. One observation is that the out put has lost its formatting and hive external table is loading NULls. However, i will take some time to dig around see how to make it right. – Naveen Venugopal Nov 29 '18 at 07:14