Skip to content

Commit 9d44110

Browse files
TylerLeonhardtdaxian-dbw
authored andcommitted
Run script in local scope to make PSReadLine works in PSES in ConstrainedLanguageMode (#1527)
1 parent 8e35e17 commit 9d44110

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PSReadLine/ReadLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ internal static PSKeyInfo ReadKey()
230230
if (ps == null)
231231
{
232232
ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
233-
ps.AddScript("0");
233+
ps.AddScript("0", useLocalScope: true);
234234
}
235235

236236
// To detect output during possible event processing, see if the cursor moved
@@ -651,7 +651,7 @@ private PSConsoleReadLine()
651651
{
652652
try
653653
{
654-
var results = ps.AddScript("$Host").Invoke<PSHost>();
654+
var results = ps.AddScript("$Host", useLocalScope: true).Invoke<PSHost>();
655655
PSHost host = results.Count == 1 ? results[0] : null;
656656
hostName = host?.Name;
657657
}

0 commit comments

Comments
 (0)