header banner

Our funding comes from our readers, and we may earn a commission if you make a purchase through the links on our website.

How to Install PowerShell Modules: Step-by-step Guide

How to Install PowerShell Modules

Hitesh J UPDATED: February 6, 2023

Microsoft’s Windows PowerShell is a configuration management framework and automation engine that comprises a command-line shell and a scripting language to perform complex tasks.

The purpose of Windows PowerShell is to automate administrative tasks, build, test, deploy, and configure commands of systems. Earlier, the administrators used Command Prompt to automate batch processes and manage customized system tools. Later in the year 2006, after the release of Powershell, system administrators as well as managed services providers (MSPs) replaced Command Prompt and preferred PowerShell with 130+ command-line tools to automate tasks for both local and remote systems.

PowerShell is cross-platform and runs on Windows, Linux, and macOS. No wonder why sysadmins and experienced Windows users mostly prefer PowerShell to automate tasks, including active directory and exchange. PowerShell is a modern and interactive Command-Line Interface (CLI) with some of the best features, including:

  • CIM cmdlets
  • Script debugging
  • It involves robust command-line history and disconnected sessions
  • Automatic loading system
  • Ability to perform complex tasks on multiple devices
  • Desired State Configuration feature for software configuration
  • Background and scheduled jobs
  • Error-handling mechanism
  • Constrained run spaces
  • Network File Transfer
  • Integrated Scripting Environment (ISE) for syntax coloring, tab completion, etc.
  • Steppable pipeline
  • PowerShell console for running cmdlets from any web browser
  • PowerShell remoting to manage remote computers

The Use of Windows PowerShell

PowerShell uses cmdlets commands and creates scripts to help administrators automate complex or time-consuming administrative tasks. Further, filter and share the computer data on a network. With its immense power and features, Windows PowerShell has become a core part of Windows Server 2008 and SQL Server 2008. Even the managed services providers (MSPs) have made up their minds to use the powerful tool for attaining more control in managing systems via text-based command-line interfaces (CLIs). The automation process will also make it much easier for MSPs (tasked with Active Directory management in a Windows network) to execute typical management tasks.

PowerShell can help perform massive configuration changes and add more granular control over Windows Management Instrumentation (WMI) and the Component Object Model (COM). Apart from this, the tool also involves the addition and deletion process of accounts, group editing, and generating listings to access specific users or groups. The popular tool uses four types of commands – cmdlets, PowerShell functions, Executable programs, PowerShell scripts.

  • It allows retrieving the USB devices from local or remote systems via Windows Management Instrumentation (WMI).
  • Instead of using the DOS prompt, you can use PowerShell to perform CMD tasks.
  • PowerShell can help end tasks within Task Manager.
  • PowerShell allows exporting NTFS permissions to view or audit ACLs for security purposes.
  • PowerShell's Background Job feature can help to execute a series of commands at once.

To build and test scripts and run commands, you can also use the Windows PowerShell Integrated Scripting Environment (ISE). This graphic user interface allows administrators to add the logic essential for developing scripts as command collections. If you need to run command sequences on a repetitive basis for system configuration, then it is an appropriate function for the administrators.

What are cmdlets?

Cmdlets is a lightweight single-function command used in the Windows PowerShell environment to perform tasks, like managing event logs, copying or retrieving data files via WMI, and swapping directories. This Microsoft .NET program is designed to simplify routine administration tasks and access data stored in files systems, directories, registries, and other places in a computer.

The command is pronounced as a command-lets and is used to implement specific functions in the PowerShell environment. To view these commands or any specific one, run “Get-Command-Type Cmdlet” in Windows PowerShell. For example, to gain information about the objects, run “Get-Member” and for changing the current directory location, run the “Get-Location” command. In Windows PowerShell, you have complete access to view 130+ commands and write your own, if needed. Cmdlets can be used individually, but using cmdlets commands within scripts is highly effective.

PowerShell design works on the .NET framework, which allows it to perform less as a simple command-line program and more as a programming language. The command is also involved in PowerShell's pipeline semantics. It consists of the use of objects as recipients in a pipeline, i.e., to pass a cmdlet’s output to the other cmdlet’s input. As a result, this mechanism allows cmdlets to work together and configure the system data. Thus, making it one of the best tools for Windows configuration.

Why is PowerShell Using the Right Option for You?

As discussed earlier, MSPs also find PowerShell as a powerful tool. The scalability and other in-built features help automate management tasks and create insights across different networks. Further, PowerShell can improve your workflow in many ways:

Automate Complex Long tasks The use of cmdlets commands eases the configuration process, and you no longer have to perform administration tasks again and again. For example,

  • Run Get-Command: to find a cmdlets
  • Run Get-Help: to discover cmdlets’ syntax and uses
  • Run Invoke-Command: to run the script locally or remotely
  • Run Get-Location or Set-Location: to reach the current directory
  • Run Move-item: to move a file to another location
  • Run Copy-item: to create a duplicate copy of a file to another location
  • Run Rename: to create a new name for an existing file
  • Run New-item: to create a new file
  • Run Get-Service: to find the list of all installed services
  • Run Convert To-HTML: allows to create of In addition, the reports with tables
  • Run Get-Process: to see all active processes on your computer

Allows working on Program limitations On a business-wide scale, the tool enables you to work on any software or program limitations, such as reconfiguring your settings on a network-wide scale. For example, if you want your users to apply a two-factor authentication process or change passwords monthly, PowerShell can work around your way.

Scalability Running scripts on multiple devices can be a daunting task, but you don't need to worry about PowerShell. The tool can run scripts on multiple devices, including remote systems. You can collect data from various devices in less time with PowerShell. Also, once enabled, the tool can send your scripts to multiple devices at once and grant access to collect data, configure and install updates in less hour.

Gain Access to More Information With the help of command-line interfaces, you can access all the information in a device file system. As a result, you can easily find the required information and later export it for reporting purposes.

Lastly, most Windows 10 devices have PowerShell pre-installed. Hence, it is not difficult to learn how to use the tool. Using PowerShell can be beneficial for a Managed Service Provider (MSP). All you require is to learn how to script cmdlets to make your process simple. As a result, PowerShell will help deliver accurate and fast service to its customers.

Windows PowerShell Vs. Command Prompt

PowerShell is not any new version of the classic command-line interpreter. The Windows PowerShell 1.0 tool replaced Command Prompt in the year 2006. However, both programs run on Windows 10, yet PowerShell turned out to be a more robust and preferred choice by many (including Managed Service Providers).

The significant difference between the tools is that PowerShell prefers cmdlets rather than using commands. Also, the Command Prompt is limited to simple commands. However, some users still prefer Command Prompt if they are aware of the language. But, most people opt for PowerShell as it is gaining too much popularity, centered on objects, and grants access to more control over a network.  Furthermore, PowerShell is an open-source tool and grants more access to system administration tasks via cmdlets than Command Prompt. It is no more limited to only Windows but also runs programs on Linux and Mac OS X.

In short, PowerShell is a more powerful tool than the replaced one – Command Prompt.

How to Install PowerShell Module in Windows Server

The simple and easiest way to install the PowerShell module is to use the PowerShell  Gallery. It contains all PowerShell modules that Microsoft and the PowerShell community have authored.

In this section, we will show you how to install the AzureAD PowerShell module.

First, open the PowerShell windows and run the following command to bypass the Windows security policy.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

bypass windows security policy

Next, install the AzureAD PowerShell module with the following command:

install-module -Name AzureAD

You will be asked to install the NuGet provider as shown below:

install nuget provider

Click on Yes to proceed with the installation. You will be asked to install the module from the untrusted repository as shown below:

install from untrusted registry

Click on the Yes to All button to install the AzureAD module.

After the installation, run the following command to verify the installation:

Get-Module -ListAvailable

You should see the following screen:

verify installed module

Next, run the following command to list all the available commands with this module:

Get-Command -module AzureAD

You should see the following screen:

list azure ad options

If you get any error during the PowerShell module installation, run the following command to set the execution policy to unrestricted:

Set-ExecutionPolicy Unrestricted

Conclusion

In 2006, PowerShell emerged as a powerful alternative tool to perform complex administrative tasks with its command-line and script language. With this tool, it became much easier for the administrators to execute and automate system management tasks. The popular PowerShell tool operates on Windows, Linux, and Mac OS X. Instead of performing time-consuming and repetitive tasks, the user can simply switch to PowerShell and create scripts or issue commands faster. Cmdlets, PowerShell functions, Executable programs, PowerShell scripts are the four main commands of PowerShell. In addition, PowerShell is an open-source and cross-platform that can also create the complete database and transaction log backups.

PowerShell became popular and unique with its amazing features like Script debugging, Automatic loading system, PowerShell remoting, steppable pipeline, Network File Transfer services, background and scheduled jobs, Error-handling mechanism, Constrained run spaces, and more.

Ηow to Install Powershell Modules FAQs

Can I install a module from a local directory?

Yes, you can install a module from a local directory by using the -Path parameter with the Install-Module cmdlet.

How do I check if a module is already installed?

You can use the Get-Module cmdlet to check if a module is already installed on your system.

How do I remove a module?

You can use the Uninstall-Module cmdlet to remove a module from your system.

Can I install a module from a different repository other than the default PowerShell Gallery?

Yes, you can install a module from a different repository by specifying the repository's URL with the -Repository parameter of the Install-Module cmdlet.

What are the prerequisites for installing a module?

The prerequisites for installing a module vary based on the module itself, but usually include having a supported version of Windows and the latest version of PowerShell installed.

How do I find available modules to install?

You can use the Find-Module cmdlet to search the default repository (PowerShell Gallery) for available modules.

footer banner