title: Dynamic variable and value assignment in powershell
body: <p>How can I declare variables and assign values to them at run time.</p>
  
  <p><em>Reason</em>: I am fetching these variables values from sql server and these variable values are configurable in nature</p>
  
  <p><em>Code which I have tried till now</em></p>
  
  <pre><code>   [array]$varArray = @($($ServerName),$($HostName)) 
  
   foreach($varname in $varArray)
          {
            $varname = "some test value"
          }
  
  Write-Host $ServerName
  Write-Host $HostName
  </code></pre>