I'm trying to automate creation of a bunch of tabs in PowerShell ISE
I've started with a function such as
function Start-NewTab($name, [ScriptBlock]$scriptBlock)
{
$tab = $psISE.PowerShellTabs.Add()
$tab.DisplayName = $name
sleep 2
$tab.Invoke($scriptBlock)
}
however when I run it like so
$v = "hello world"
Start-NewTab "Test" { $v }
hello world
isn't shown, unlike the following fragement
function Test-ScriptBlock([ScriptBlock]$sb) { & $sb }
Test-ScriptBlock { $v }
What's going on here and how do I fix it?