Say I have a hashtable like this:
$headers = @{
'Content-Type'='application/json'
'Authorization'= "Api-Key 123456789"
}
When I run that, I get the hashtable placed in the $headers variable.
My question is, is there a way, using one line of code) to get it write back out like this?
@{'Content-Type'='application/json'; 'Authorization'= "Api-Key 123456789" }
The closest I can come is something like this:
$headers.GetEnumerator() | ForEach-Object{"`"$($_.Name)`" = `"$($_.Value)`";"}
But that has the output on two lines, and adds an extra ; and does not have the surrounding @{ }