Using PowerShell 7 in The Windows PowerShell ISE
Using PowerShell 7 in The Windows PowerShell ISE
com
Images are still loading. Please cancel your print and try again.
Skip to content
Ironman Software Logo
Different Architectures
To learn more about the difference between .NET Core and .NET
Framework, check out this article.
Local Remoting
Since there is the issue of different architectures, we need to start a
new PowerShell process to actually host the PowerShell 7 runtime.
We can then use remoting to connect to the pwsh.exe process. We
can use the named pipe transport of PowerShell remoting to
establish a connection to the remote process. Once the connection
is established, we can push the runspace to the current host and
execute commands against PowerShell 7 via the ISE.
Step-by-step
function New-OutOfProcRunspace {
param($ProcessId)
$tt = [System.Management.Automation.Runspaces.TypeTable]::LoadDefaultTypeFiles()
$Runspace =
[System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace(
$Host, $tt)
$Runspace.Open()
$Runspace
$Host.PushRunspace($Runspace)
In our augmented PowerShell ISE console, you’ll see that the Split-
Path cmdlet does in fact contain the -LeafBase parameter that has
been added in future versions.
Caveat
One problem is that the 1903 update of Windows broke the ISE’s
ability to use the Out-Default cmdlet when using remoting. You’ll
receive the error “Remote host method get_WindowSize is not
implemented.”. To resolve this issue, you’ll need to override the
Out-Default cmdlet. This can be done by using a steppable pipeline
and Out-String.
function Out-Default
param(
[switch]
$Transcript,
[Parameter(ValueFromPipeline=$true)]
[psobject]
$InputObject
begin
$pipeline = { Microsoft.PowerShell.Core\Out-Default
@PSBoundParameters
}.GetSteppablePipeline($myInvocation.CommandOrigin)
$pipeline.Begin($PSCmdlet)
$Arr = @()
process
{
$pipeline.Process($_)
$Arr += $_
end
$pipeline.End()
$Arr | Out-String
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 7
{
function New-OutOfProcRunspace {
param($ProcessId)
$tt = [System.Management.Automation.Runspaces.TypeTable]::LoadDefaultTypeFiles()
$Runspace =
[System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace(
$Host, $tt)
$Runspace.Open()
$Runspace
$Host.PushRunspace($Runspace)
}, "ALT+F5") | Out-Null
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to Windows
PowerShell", {
$Host.PopRunspace()
}, "ALT+F6") | Out-Null
Related Posts