Tim Van Wassenhove home

Sometimes you only know at runtime in which variable a certain value is stored. Let me clarify with an example:

$tim = 30;
$evy = 24;
$name = Read-Host "Enter your name";

In essence, if $name equals tim we want to use $tim and if $name equals evy we want to use $evy. This can be achieved with Get-Variable:

$age = Get-Variable $name -valueOnly;
Write-Host "Your age is $age";