I expected this code to run Foo():
function Foo {
[Console]::WriteLine("Foo")
}
$Bar = [Console]::ReadLine()
# If $Bar is Foo then it should do the function "Foo", right?
$Bar()
Functions in powershell follow a verb-noun pattern and most .NET methods have a powershell equivalent known ascmdlet so your function can be :
function Get-Foo {
#[Console]::WriteLine('Foo')
Write-Host 'This is foo'
}
Get-Foo
or
$Bar = Get-Foo
$Bar
Get-Command and Get-Help are your friends, try them out.
[console]::readline() which will always be a string.... foo function` and foo string are not the same thing