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