I am trying to run docker commands in powershell and then record the output. The problem is that when you run a docker command in powershell for instance “docker images” , what is returned is a list strings. The structure of columns and values is not available.
If ConvertFrom-String doesn’t work, it’s tough to really help without having the actual text. The formatting is going to be space or tab delimited, so you can use ConverFrom-CSV to manipulate the string into an object:
$testSpaces = @"
REPOSITORY TAG IMAGEID
blue latest {GUID}
red latest {GUID}
purple latest {GUID}
"@
#Replace more than on space with semi-colon
$testSpaces -replace "[ ]{2,}", ";"
$testSpaces | ConvertFrom-CSV -Delimiter ";"
ConvertTo-String worked a treat , just a matter of working out the format for the template.
It will have to be unique for every command but otherwise works perfect.
Thank you for the reply.
You are correct in the that error was due to the ConvertFrom-String parameter of -TemplateFile was expecting a file path but my real issue was that i was using -TemplateFile in the first place, where as i should have been using -TemplateContent with the $variable.
I couldn’t see the forrest through the trees.
Always learning
Rob ,
I have to say that it was your post that pointed me to my problem as your answer had me wondering why i my code was using a filepath, it was then that i realized that i was using the incorrect parameter.
So thank you for the answer and the light you shined on my mistake else i would still be wonder what was up.