PowerShell 5.1 To PowerShell 7 - PowerShell - Microsoft Learn
PowerShell 5.1 To PowerShell 7 - PowerShell - Microsoft Learn
Designed for cloud, on-premises, and hybrid environments, PowerShell 7 is packed with
enhancements and new features.
PowerShell 7 works side-by-side with Windows PowerShell letting you easily test and compare
between editions before deployment. Migration is simple, quick, and safe.
PowerShell 7 also runs on macOS and several Linux distributions. For a list of supported
operating systems and information about the support lifecycle, see the PowerShell Support
Lifecycle.
Installing PowerShell 7
For flexibility and to support the needs of IT, DevOps engineers, and developers, there are
several options available to install PowerShell 7. In most cases, the installation options can be
reduced to the following methods:
7 Note
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 1/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
The MSI package can be deployed and updated with management products such as
Microsoft Configuration Manager. Download the packages from GitHub Release
page .
Deploying the MSI package requires Administrator permission. The ZIP package can be
deployed by any user. The ZIP package is the easiest way to install PowerShell 7 for testing,
before committing to a full installation.
You may also install PowerShell 7 via the Windows Store or winget . For more information
about both of these methods, see the detailed instructions in Installing PowerShell on
Windows.
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 2/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
The new location is added to your PATH allowing you to run both Windows PowerShell 5.1 and
PowerShell 7. If you're migrating from PowerShell 6.x to PowerShell 7, PowerShell 6 is removed
and the PATH replaced.
Separate PSModulePath
By default, Windows PowerShell and PowerShell 7 store modules in different locations.
PowerShell 7 combines those locations in the $Env:PSModulePath environment variable. When
importing a module by name, PowerShell checks the location specified by $Env:PSModulePath .
This allows PowerShell 7 to load both Core and Desktop modules.
ノ Expand table
The following examples show the default values of $Env:PSModulePath for each version.
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 3/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
PowerShell
Output
C:\Users\<user>\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\System32\WindowsPowerShell\v1.0\Modules
For PowerShell 7:
PowerShell
Output
C:\Users\<user>\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
C:\Program Files\PowerShell\7\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\System32\WindowsPowerShell\v1.0\Modules
Notice that PowerShell 7 includes the Windows PowerShell paths and the PowerShell 7 paths
to provide autoloading of modules.
7 Note
Additional paths may exist if you have changed the PSModulePath environment variable
or installed custom modules or applications.
Separate profiles
A PowerShell profile is a script that executes when PowerShell starts. This script customizes
your environment by adding commands, aliases, functions, variables, modules, and PowerShell
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 4/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
drives. The profile script makes these customizations available in every session without having
to manually recreate them.
PowerShell
Output
7 Note
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 5/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
PowerShell Remoting
PowerShell remoting lets you run any PowerShell command on one or more remote
computers. You can establish persistent connections, start interactive sessions, and run scripts
on remote computers.
WS-Management remoting
Windows PowerShell 5.1 and below use the WS-Management (WSMAN) protocol for
connection negotiation and data transport. Windows Remote Management (WinRM) uses the
WSMAN protocol. If WinRM has been enabled, PowerShell 7 uses the existing Windows
PowerShell 5.1 endpoint named Microsoft.PowerShell for remoting connections. To update
PowerShell 7 to include its own endpoint, run the Enable-PSRemoting cmdlet. For information
about connecting to specific endpoints, see WS-Management Remoting in PowerShell
To use Windows PowerShell remoting, the remote computer must be configured for remote
management. For more information, including instructions, see About Remote Requirements.
For more information about working with remoting, see About Remote
SSH-based remoting
SSH-based remoting was added in PowerShell 6.x to support other operating systems that
can't use Windows native components like WinRM. SSH remoting creates a PowerShell host
process on the target computer as an SSH subsystem. For details and examples on setting up
SSH-based remoting on Windows or Linux, see: PowerShell remoting over SSH.
7 Note
The PowerShell Gallery (PSGallery) contains a module and cmdlet that automatically
configures SSH-based remoting. Install the Microsoft.PowerShell.RemotingTools module
from the PSGallery and run the Enable-SSH cmdlet.
The New-PSSession , Enter-PSSession , and Invoke-Command cmdlets have new parameter sets to
support SSH connections.
PowerShell
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 6/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
To create a remote session, specify the target computer with the HostName parameter and
provide the user name with UserName. When running the cmdlets interactively, you're
prompted for a password.
PowerShell
Alternatively, when using the HostName parameter, provide the username information
followed by the at sign ( @ ), followed by the computer name.
PowerShell
You may set up SSH key authentication using a private key file with the KeyFilePath parameter.
For more information, see OpenSSH Key Management.
Group Policy tools use administrative template files ( .admx , .adml ) to populate policy settings
in the user interface. This allows administrators to manage registry-based policy settings. The
InstallPSCorePolicyDefinitions.ps1 script installs PowerShell Administrative Templates on the
local machine.
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 7/9
7/11/24, 1:59 AM Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn
PowerShell
Output
PowerShell
To make the transition to Visual Studio Code easier, use the Enable ISE Mode function
available in the Command Palette. This function switches VSCode into an ISE-style layout. The
ISE-style layout gives you all the new features and capabilities of PowerShell in a familiar user
experience.
To switch to the new ISE layout, press Ctrl + Shift + P to open the Command Palette, type
PowerShell and select PowerShell: Enable ISE Mode.
To set the layout to the original layout, open the Command Palette, select PowerShell: Disable
ISE Mode (restore to defaults).
For details about customizing the VSCode layout to ISE, see How to Replicate the ISE
Experience in Visual Studio Code
7 Note
There are no plans to update the ISE with new features. In the latest versions of Windows
10 or Windows Server 2019 and higher, the ISE is now a user-uninstallable feature. There
are no plans to permanently remove the ISE. The PowerShell Team and its partners are
focused on improving the scripting experience in the PowerShell extension for Visual
Studio Code.
Next Steps
Armed with the knowledge to effectively migrate, install PowerShell 7 now!
6 Collaborate with us on
GitHub PowerShell feedback
PowerShell is an open source project.
The source for this content can
Select a link to provide feedback:
be found on GitHub, where you
can also create and review issues
Open a documentation issue
and pull requests. For more
information, see our contributor
Provide product feedback
guide.
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4 9/9