I am struggling to be able to run a command and attach to variable in windows!
On mac I would run:
export TOKEN="$(curl --header "Metadata-Flavor: Google" --get --data-urlencode "audience=http://vault/${ROLE}" --data-urlencode "format=full" "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity")"
But struggling to run same on windows (have tried piping output using >
but no luck)!
What am I obviously missing!
You can assign the output of any command in PowerShell by just using this syntax.
$myNewVar = hostname #or any other command
What will happen is that the output of the command is consumed and stored in the variable, so nothing gets output to the screen.
if you want to assign a variable while also outputting to the screen, us the Tee
command.
hostname | tee-object -variable myNewVar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With