The short story is that I am writing a script that will open new tabs in Windows Terminal. I would like to rename each tab using this command: $wshell.SendKeys("$Host.UI.RawUI.WindowTitle = 'test'{ENTER}")
. However, I receive the error below.
Running $Host.UI.RawUI.WindowTitle = 'test'{ENTER}
directly in a PowerShell does work. It is when I am passing it to a new PowerShell that I am having this issue. Is it possible for me to rename this new tab using a PowerShell script?
The complete code block:
wt new-tab -p PowerShell -noExit
Start-Sleep -s 0.5s
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('PowerShell')
Start-Sleep -s 0.5
$wshell.SendKeys("$Host.UI.RawUI.WindowTitle = 'test'{ENTER}")