title: Powershell: retrieve variable type after using Get-Variable
body: <p>In PowerShell, I've a ScriptBlock variable: </p>
  
  <p><code>$my_scriptblock = {
      ....
  }</code></p>
  
  <p>If I do <code>$my_scriptblock.GetType().Name</code> I get the type as <code>ScriptBlock</code> correctly.</p>
  
  <p>But I'm using <code>Get-Variable</code> to collect all the user variables (I need it for some reason). But when I collect the variables using <code>Get-Variable</code>, they are converted to type <code>PSVariable</code>.</p>
  
  <p>How do I get the variable type of a variable/object that is returned by <code>Get-Variable</code>?</p>
  
  <p>Edit: more info</p>
  
  <p><code>$my_scriptblock_var = Get-Variable | Where-Object { ('my_scriptblock' -Contains $_.name) }</code></p>
  
  <p>Now, if you do <code>$my_scriptblock_var.GetType().Name</code> I get the type as <code>PSVariable</code>. Which is correct, <code>Get-Variable</code> will return an object it is designed to return. </p>
  
  <p>My question is how do I get the original Type back?</p>
  
  <p>Also, is there an alternate method I should consider to collect all user variables?</p>