title: Create show-menu in powershell depending on variables
body: <p>I want to create a menu with show-menu that will depend on what is present on the computer.</p>
  
  <p>I want to list in the menu usernames available on c:\users\ (based on the folders names).</p>
  
  <p>For example :
  in c:\users
  there is folder nammed :</p>
  
  <pre><code>homer.simpson
  lisa.simpson
  bart.simpson
  </code></pre>
  
  <p>and with show-menu ask the user to choose one of them by typing 1 for homer.simpson 2 for lisa.simpson etc ..</p>
  
  <p>How can i do it ? </p>
  
  <p>Thank you in advance ! </p>
  
  <p>EDIT : Code </p>
  
  <pre><code>$users = Get-ChildItem "$env:SystemDrive\Users"| ForEach-Object { $_.Name }
  
  foreach ($user in $user)   {
  
  $user
  $num++ 
  
  New-Variable -Name "a$num" -Value $user
  #Get-Variable -Name "$user$i" 
  
  }
  
  
  
  function Show-Menu
  {
       param (
             [string]$Title = 'Please select an user'
       )
       cls
       Write-Host "================ $Title ================"
  
       Write-Host "1: $a1"
       Write-Host "2: $a2"
       Write-Host "3: $a3"
       Write-Host "Q: $a4"
  }
  
  
  do
  {
       Show-Menu
       $input = Read-Host "Please make a selection"
       switch ($input)
       {
             '1' {
                  cls
                  'You chose option #1'
             } '2' {
                  cls
                  'You chose option #2'
             } '3' {
                  cls
                  'You chose option #3'
             } 'q' {
                  return
             }
       }
       pause
  }
  until ($input -eq 'q')
  </code></pre>