Don’t do that #2: Multiple lines to read variables

By | February 24, 2015

Don’t do that: The following code requires multiple lines to read variables.


Do that: It’s possible to read multiple variables in one line and display the name/value:
1..10 | ForEach-Object -Process {Get-Variable -Name number$_}

(or using a for loop)


previous-buttonnext-button

2 thoughts on “Don’t do that #2: Multiple lines to read variables

  1. Pingback: Don't do that #1 : Multiple lines to initialize variables - Powershell Guru

  2. Pingback: Don't do that #3 : Multiple Write-Host to add new lines - Powershell Guru

Leave a Reply

Your email address will not be published. Required fields are marked *