Windows server powershell install

Published December 16, 2023 by Danny Moran

Learn how to install PowerShell 7 on Windows Server and how to execute scripts using either PowerShell 7 or PowerShell 5. In this example, I show you how to download the PowerShell 7 MSI, go through the installer options, and then how you can execute PowerShell scripts using the newly installed PowerShell 7.

  • Go to the download page linked above and download the PowerShell 7 installation files.

    Note: I recommend using the MSI installation package.

  • Copy the MSI installation package to the local server.

  • Right-click the installation MSI package and press Install.

  • Select Next on the welcome page of the installation wizard.

  • Enter the installation directory and press Next.

    Note: I recommend leaving this as the default of C:\Program Files\PowerShell\.

  • Select the optional installation settings and then press Next.

    • Add PowerShell to Path Environment Variables: This is enabled by default.

      This setting adds the PowerShell 7 application to the %PATH% environment so that you can run pwsh.exe from the commandline without having the PowerShell 7 executable in that file location.

    • Register Windows Event Logging Manifest: This is enabled by default.

      This setting enables logging to the Windows event log.

    • Enable PowerShell remoting: This is disabled by default.

      This setting enables PowerShell remoting.

    • Disable Telemetry: This is disabled by default.

      This setting stops telemetry information from being sent to Microsoft.

    • Add ‘Open here’ context menus to Explorer: This is disabled by default.

      This setting enables a PowerShell 7 terminal to be easily opened by right-clicking anywhere in Explorer and selecting open in PowerShell 7.

    • Add ‘Run with PowerShell 7’ context menu for PowerShell files: This is disabled by default.

      This setting enables you to right-click .ps1 files and execute them from Explorer easily.

  • Select the automatic update options that you want to use and then press Next.

    • Enable updaing PowerShell 7 through Microsoft UPdate or WSUS (recommended)
    • Use Microsoft Update when I check for updates (recommended)

    Note: I recommend leaving these settings as default (which is enabled).

  • Select Install to start the installation process.

  • Once the installation has finished, select Finish to close the wizard.

  • PowerShell 7 is now installed.

  • It’s no secret that PowerShell is a very powerful and useful tool. That usefulness, though, can be expanded by adding modules such as Active Directory and Office 365 modules. There are even non-Microsoft modules that can be installed such as VMWare’s PowerCLI, which let you take administrating vSphere to another level.

    Though, I’m going to go out on a limb and guess that because you’re here, you already know this and you want to know HOW to install those modules.

    Am I right?

    Well let’s jump in then!

    Downloading and Installing PowerShell Modules

    There are several ways to install PowerShell modules but we are going to look at the easiest way first. The basic steps are to determine your current PowerShell module directory path, download your new module to that path, and then invoke the import-module command to let windows know it’s there.

    Let’s see it in action.

    List PowerShell Module Environment Variable Path

    We need to determine the install path for our PowerShell Modules so we know where to put new modules. To do this, open a PowerShell window on your Windows 10 or Windows Server machine and run the following command:

    $ENV:PSModulePath

    The output should look similar to:

    PS C:\WINDOWS\system32> $ENV:PSModulePath
    
    C:\Users\UserName\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

    You’ll see two important paths here:

    C:\Users\UserName\Documents\WindowsPowerShell\Modules
    C:\Program Files\WindowsPowerShell\Modules

    Make a mental note of these paths, we’ll use one or both of them later. The first path is that path you would place a new PowerShell module that you only want that specific user to have access to. The second path would make the module available for all users on the computer.

    The third path we received with the $ENV:PSModulePath command is the path Windows uses for built-in modules that are already installed when you install Windows.

    Download New PowerShell Module to Environment Variable Path

    Armed with the path we wish to use (from above) we can source our PowerShell Module and copy it to the location specified in the path.

    Here I’ve downloaded the PowerNet PowerShell module from CodePlex and placed it in the directory that will allow all users on the computer to load the module.

    Screenshot showing powershell install directory

    I then run the following command to make sure the module is listed as available:

    Get-Module -ListAvailable

    Which gives me the following output, where we can clearly see the PowerNet module listed:

    PS C:\WINDOWS\system32> get-module -listavailable
    
        Directory: C:\Program Files\WindowsPowerShell\Modules
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Script     1.0.1      Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
    Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
    Script     3.4.0      Pester                              {Describe, Context, It, Should...}
    Script     0.0        PowerNet                            {Test-TCPPort, Enable-Monitoring, Disable-Monitoring, Writ...
    Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
    Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remov...

    Import New PowerShell Module

    With our new module in place we just need to tell Windows to load it so that we can use it in our current PS Session.

    To this, I will run this command:

    Import-Module -Name PowerNet

    You may receive the following warning:

    Security warning
    Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
    computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
    message. Do you want to run C:\Program Files\WindowsPowerShell\Modules\PowerNet\PowerNet.psm1?
    [D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"):

    Type R to run once, assuming you’re sure this is a safe module.

    If you receive the following error when trying to load your module:

    import-module : File C:\Program Files\WindowsPowerShell\Modules\PowerNet\PowerNet.psm1 cannot be loaded because running scripts is disabled on this system.

    You may need to run the following command to allow loading the module:

    Set-ExecutionPolicy Unrestricted

    Be sure to set it back to restricted when you’re finished, using the following command:

    Set-ExecutionPolicy Restricted

    It should be obvious, but I’ll state it anyway, be careful loading PowerShell modules from the internet. These are scripts and can contain malicious code. Only load modules you trust and that are from a trusted source.

    With that said, we are finished with this method of loading PowerShell Modules. Try it out and let me know if you have any trouble with it!

    The other way we can install PowerShell modules is to use the PowerShell Gallery. These will be modules that have been authored by Microsoft and the PowerShell community. You’ll install them through PowerShell directly from the internet. That also means you’ll need to make sure that your firewall and content/web filter allow connections from your computer to the internet through PowerShell. I won’t get into that here, though.

    The process is simple but we need to step through a couple prerequisites first.

    Verify You Have the PowerShellGet Module

    Windows 10, Windows Server 2019, Windows Management Framework (WMF) 5.0, and PowerShell 6 are all shipped with PowerShellGet. If you’re running any of those you’re good to go here.

    If you are running an OS older than Windows 10 or using a PowerShell older than 6.0 you’ll need to download the PowerShellGet msi here.

    Update Nuget

    PowerShellGet relies on the provider named Nuget. Always start with the latest version by running the following command:

    Install-PackageProvider Nuget –Force

    Update PowerShellGet

    We also need to make sure your PowerShellGet install is on the latest update. Do this by running:

    Install-Module –Name PowerShellGet –Force

    Install PowerShell Module from Gallery

    To install a module we just need to know it’s name. The gallery page will tell you what the command is to install the module. I’ve found a module on the gallery named SqlServer that I wish to install so I’ll run the following command:

    Install-Module -Name SqlServer

    After which I receive the following message:

    Untrusted repository
    You are installing the modules from an untrusted repository. If you trust this repository, change its
    InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
    'PSGallery'?
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

    I will answer Y which will commence installing the module which I can see visually by the loading text at the top of the window:

    Screenshot showing installing powershell module gallery

    And that’s it! Pretty slick huh? Try it out and let me know if you have any issues!

    Recommended Tool: ManageEngine OpManager

    • Multi-vendor Network Monitoring
    • Simple Installation & Setup
    • Intuitive UI
    • Complete Visibility
    • Intelligent Detections
    • Easy Resolutions

    Network Engineer III

    I am a Senior Network Engineer who has spent the last decade elbow deep in enterprise System Administration and Networking in the local government and energy sectors. I can usually be found trying to warm up behind the storage arrays in the datacenter.

    Posted

    Updated

    Steps on how to install PowerShell 7 with ISE Mode in Windows 2019 Server

    Download and install the MSI Package of PowerShell 7 x64 (Around 90MB)

    Default installation folder is *C:\Program Files\PowerShell*

    Open the New PowerShell 7 (x64) from start menu, and verify it is installed successfully with $PSVersionTable

    PowerShell 7.0.0
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    https://aka.ms/powershell
    Type 'help' to get help.
    
    PS C:\Users\administrator.LAB> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      7.0.0
    PSEdition                      Core
    GitCommitId                    7.0.0
    OS                             Microsoft Windows 10.0.17763
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    

    Download and install Visual Studio code

    Install PowerShell 2020.3.0 Extension

    Press F1 to activate the command plate and select PowerShell:Enabled ISE Mode

    The Visual Studio Code is changed to the familiar ISE Environment

    Refer to the link below for more information

    https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/how-to-replicate-the-ise-experience-in-vscode?view=powershell-7

    #Installing and configuring PowerShell 7.2.1 on 64-bit Server 2019 and Windows 10

    #The installation commands shown here are for the latest stable release of PowerShell 7. 

    #To be honest I don’t recommend upgrading if you plan to keep using all your existing scripts and commands without issue.  That most likely will not happen. PowerShell 7 doesn’t work well with Microsoft 365 and Microsoft Azure.  The login command fails, for example.  There might be a work around using the Microsoft Graph API but I haven’t managed to get that working.  The differences between PowerShell 5 and PowerShell 7 are discussed here.

     #I need to use the older Microsoft only releases of PowerShell for most of what I do.  PowerShell 7 does work on many non-Windows platforms but do not expect to use PowerShell 7 to manage your hard drives in Linux.  PowerShell 5.x and PowerShell 6.x only work on Microsoft Windows-based computers.

    #It should also be mentioned that PowerShell 5 and PowerShell 7 run along side each other and is determined by which shell you choose to work in.  Another problem is that PowerShell ISE is not designed to work with PowerShell 7 and not included.


    From Microsoft: 

    #Is PowerShell ISE going away?

    The PowerShell ISE is no longer in active feature development. As a shipping component of Windows, it continues to be officially supported for security and high-priority servicing fixes. … Users looking for replacement for the ISE should use Visual Studio Code with the PowerShell Extension.


    PowerShell 7.2.1 can be downloaded for 64-bit Windows-based operating systems from the link below: 

    https://github.com/PowerShell/PowerShell/releases/download/v7.2.1/PowerShell-7.2.1-win-x64.msi

    Get more information about the latest version of Microsoft PowerShell 7.2 LTS from the link below:

    https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2


    #Open firewall to allow PowerShell access to and from other computers on your network:

    SetNetConnectionProfile NetworkCategory Private

    EnablePSRemoting

    Provide feedback

    Saved searches

    Use saved searches to filter your results more quickly

    Sign up

    Appearance settings

    Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии
  • Поиск по тексту документа в windows 10
  • Установка apache на windows server 2008
  • Node js download for windows 10
  • Как запустить ноутбук леново в безопасном режиме windows 10 при загрузке
  • Запуск приложения через терминал windows