red888
red888

Reputation: 31610

Display a variable's name along with output?

Sometimes when I'm writing a script I want to dump the value of a bunch of variables in my script to the console along with the variable's name.

Instead of having to do "var1: $var1" for all of my variables is there a powershellism that can display a bunch of variables along with their names? Is there some kind of convenient reflectiony thing for this?

Upvotes: 2

Views: 119

Answers (1)

user4003407
user4003407

Reputation: 22132

You can use Get-Variable cmdlet, which return PSVariable objects to you. By default, them formatted as table with two columns: Name and Value.

Upvotes: 3

Related Questions