The PowerShell ISE built into Windows works with Windows PowerShell only and is stuck at PowerShell version 5.1. Typically, when you want to use an editor to write PowerShell 7 code, Visual Studio Code and the PowerShell extension is the way to go.
Still, you can make PowerShell ISE “talk” to PowerShell 7. It then provides rich IntelliSense for PowerShell 7 and understands all language features that were introduced in PowerShell 7.
For this, you start a local remoting session from within the PowerShell ISE, and specify the configuration name “powershell.7”.
PS> Enter-PSSession -ComputerName localhost -ConfigurationName powershell.7
This of course requires a number of prerequisites:
- You need to install PowerShell 7 before you can use it. PowerShell 7 does not ship with Windows.
- You need to enable remoting in PowerShell 7. You can do this either during installation by checking the appropriate box in the install dialog. Or, you run this command from an elevated PowerShell 7 console: Enable-PSRemoting -SkipNetworkProfileCheck -Force
- You might need to run this line again in an elevated Windows PowerShell: Enable-PSRemoting -SkipNetworkProfileCheck -Force
Now you should be all set, and when you run Enter-PSSession with the parameters above, you remote into PowerShell 7.
If your current user is no Administrator, or you logged on with your email address and a Microsoft account, you need to create a local user account with Administrator privileges and use it explicitly for authentication:
PS> Enter-PSSession -ComputerName localhost -ConfigurationName powershell.7 -Credential localAdminUser