How to Install PowerShell Modules – Step by Step

How to Install PowerShell Modules – Step by Step

Windows PowerShell was created to automate administrative activities, as well as building, testing, deploying, and configuring system commands. In the past, administrators would make use of the Command Prompt to automate batch processes and handle specialized system tools. After the release of Powershell later in the year 2006, system administrators and managed services providers (MSPs) began replacing Command Prompt with PowerShell as their preferred method of automating tasks for both local and remote systems. PowerShell comes equipped with over 130 command-line tools.

PowerShell is compatible with multiple operating systems and may be executed on Windows, Linux, and macOS. It should come as no surprise that system administrators and experienced Windows users favor PowerShell as their tool of choice for automating operations such as active directory and exchange.

PowerShell is an up-to-date and interactive Command-Line Interface (CLI) that comes equipped with some of the industry’s top capabilities, such as:

  • CIM cmdlets
  • Script debugging
  • It requires a comprehensive command-line history as well as disconnected sessions.
  • Capability to carry out difficult responsibilities across a variety of devices
  • A function known as Desired State Configuration is used for setting up software
  • Jobs in the background and those that are scheduled
  • Error-handling technique
  • Running areas with limited free space
  • Transfer of Files Over a Network
  • The Integrated Scripting Environment (ISE), includes features like syntax coloring and tab completion, among other things.

The Use of Windows PowerShell

To assist administrators in automating laborious or time-consuming administrative activities, PowerShell makes use of commands known as cmdlets and produces scripts. In addition, the data on the computer should be filtered and shared through a network. Windows PowerShell has become an essential component of both Windows Server 2008 and SQL Server 2008 as a result of its extensive functionality and strength.

Even managed service providers (MSPs), who traditionally administer their clients’ systems through the use of text-based command-line interfaces, have concluded that it is in their best interest to take advantage of the powerful technology (CLIs). MSPs, who are assigned with Active Directory management in a Windows network, will find it considerably simpler and less time-consuming to carry out typical management duties as a result of the automation process.

The Windows Management Instrumentation (WMI) and the Component Object Model can be controlled in a more granular manner and large configuration changes can be carried out with the assistance of PowerShell (COM). In addition to this, the tool allows for the creation and deletion of user accounts, the modification of group membership, and the generation of listings that may be used to access particular people or groups.

The well-known application makes use of cmdlets, PowerShell functions, Executable programs, and PowerShell scripts as its several kinds of instructions.

  • Using Windows Management Instrumentation, it is possible to get the USB devices from either the local system or a remote system (WMI).
  • When you need to conduct CMD operations, you can utilize PowerShell instead of the DOS prompt to get the job done.
  • It is possible to terminate tasks using PowerShell while working in Task Manager.
  • Exporting NTFS permissions to see or audit ACLs for purposes of security is possible through the use of PowerShell.
  • Using the Background Job feature of PowerShell is a useful way to perform multiple commands at the same time.

You can also make use of the Windows PowerShell Integrated Scripting Environment to create scripts, test those scripts, and run commands (ISE). With the help of this graphical user interface, administrators can add the logic that is necessary when constructing scripts as a collection of commands. If you need to run command sequences on a repetitive basis to configure the system, then this is the kind of function that should be delegated to the administrators.

PowerShell Modules Downloading and Installation Process

There are a few different approaches to installing PowerShell modules, but in this lesson, we are going to focus on the most straightforward one. The first step is to find out where your current PowerShell module directory path is, then download your new module to that directory, and finally run the import-module command so that Windows is aware it’s there. These are the fundamental steps.

The PowerShell Module Environment Variable Path will be listed.

We must figure out the install path for our PowerShell Modules so that we are aware of where to place any new modules. To accomplish this, launch PowerShell and type the following command into the console:

You’ll notice that there are two significant routes here:

C:\Users\UserName\Documents\

WindowsPowerShell\Modules

Modules can be found in the C:Program FilesWindowsPowerShell folder.

Make a note of these routes in your head; we’ll be using either one or both of them later. The first path is the one in which you would put a new PowerShell module in which you want that particular user to be the only one who can access it. Taking the second option would result in the module being accessible to every user on the computer.

The third path that we were given with the $ENV:PSModulePath command is the path that Windows uses for built-in modules, which are modules that are preloaded on a computer when the operating system is installed.

The new PowerShell module can be downloaded to the environment variable path. After acquiring the path that we want to utilize (from the previous section), we can source our PowerShell Module and then copy it to the location that is indicated in the path.

I have downloaded the PowerNet PowerShell module from CodePlex and placed it in the directory where it can be loaded by any user on this machine. This makes it possible for any user to utilize the module. After that, I make sure that the module is displayed as available by executing the command that follows: Get-Module -ListAvailable

Import a New Module into PowerShell

Now that our new module has been installed, all that is left to do is instruct Windows to load it so that we can make use of it in the PS Session that we are now working in

If you are certain that this is a secure module, type R to run it once. When attempting to load your module, if you encounter the following error:

import-module: File located in “C:Program FilesWindowsPowerShellModulesPowerNet”

The PowerNet.psm1 file cannot be loaded on this machine because the ability to execute scripts has been disabled. You may need to execute the following command to enable the loading of the module:

Unrestricted Set-ExecutionPolicy

After you are completed, you must remember to use the following command to revert it to its restricted state:

Restricted Set-ExecutionPolicy Execution

Be extremely cautious when loading PowerShell modules from the internet; even though this should go without saying, I’ll say it anyway. These are scripts, which means they have the potential to contain dangerous code. Loading modules is only allowed if they have your full confidence and come from a reliable source.

With that out of the way, we can now consider this approach to loading PowerShell Modules completely. Give it a shot, and be sure to report back to me if you run into any problems with it.

PowerShell Modules installation from the PowerShell Gallery

Using the PowerShell Gallery is the alternative method for installing PowerShell modules that we can employ. These are going to be modules that have been created by members of the PowerShell community as well as Microsoft. You will download them directly from the internet and install them using PowerShell. Because of this, you will also need to check that the firewall and content/web filter on your computer allows connections to be made from your computer to the internet through PowerShell. But I’m not going to go into that right now.

Although the method is straightforward, there are a few conditions that must be met before we can move forward.

Install PowerShell Module from the PowerShell Gallery

The simple and easiest way to install the PowerShell module is to install it from the PowerShell gallery. Follow the below steps to install the PowerShell module:

Step 1

First, you will need to install the Nuget package on your system. You can install it by running the following command:

Install-PackageProvider Nuget –Force

Once installed, you should see the following output:

Name Version Source Summary

—- ——- —— ——-

nuget 2.8.5.208 https://onege… NuGet provider for the OneGet meta-package manager

Step 2

Next, you will also need to install the PowerShellGet on your system. PowerShellGet is a module that provides commands to find, update and publish modules, scripts, and resources. You can install it with the following command:

Install-Module –Name PowerShellGet –Force

Step 3 

Now, let’s install the module named NTFSSecurity from the PowerShell gallery using the following command:

Install-Module -Name NTFSSecurity

You will get the following warning:

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”):

Answer Yes to All and press the Enter key to install the NTFSSecurity module.

Step 4

You can now see the detailed information about the installed module by running the following command:

Get-Command -module NTFSSecurity

You will get the following output:

CommandType Name Version Source

———– —- ——- ——

Cmdlet Add-NTFSAccess 4.2.6 NTFSSecurity

Cmdlet Add-NTFSAudit 4.2.6 NTFSSecurity

Cmdlet Clear-NTFSAccess 4.2.6 NTFSSecurity

Cmdlet Clear-NTFSAudit 4.2.6 NTFSSecurity

Cmdlet Copy-Item2 4.2.6 NTFSSecurity

Cmdlet Disable-NTFSAccessInheritance 4.2.6 NTFSSecurity

Cmdlet Disable-NTFSAuditInheritance 4.2.6 NTFSSecurity

Cmdlet Disable-Privileges 4.2.6 NTFSSecurity

Cmdlet Enable-NTFSAccessInheritance 4.2.6 NTFSSecurity

Cmdlet Enable-NTFSAuditInheritance 4.2.6 NTFSSecurity

Cmdlet Enable-Privileges 4.2.6 NTFSSecurity

Cmdlet Get-ChildItem2 4.2.6 NTFSSecurity

Cmdlet Get-DiskSpace 4.2.6 NTFSSecurity

Cmdlet Get-FileHash2 4.2.6 NTFSSecurity

Cmdlet Get-Item2 4.2.6 NTFSSecurity

Cmdlet Get-NTFSAccess 4.2.6 NTFSSecurity

Cmdlet Get-NTFSAudit 4.2.6 NTFSSecurity

Cmdlet Get-NTFSEffectiveAccess 4.2.6 NTFSSecurity

Cmdlet Get-NTFSHardLink 4.2.6 NTFSSecurity

Cmdlet Get-NTFSInheritance 4.2.6 NTFSSecurity

Cmdlet Get-NTFSOrphanedAccess 4.2.6 NTFSSecurity

Cmdlet Get-NTFSOrphanedAudit 4.2.6 NTFSSecurity

Cmdlet Get-NTFSOwner 4.2.6 NTFSSecurity

Cmdlet Get-NTFSSecurityDescriptor 4.2.6 NTFSSecurity

Cmdlet Get-NTFSSimpleAccess 4.2.6 NTFSSecurity

Cmdlet Get-Privileges 4.2.6 NTFSSecurity

Cmdlet Move-Item2 4.2.6 NTFSSecurity

Cmdlet New-NTFSHardLink 4.2.6 NTFSSecurity

Cmdlet New-NTFSSymbolicLink 4.2.6 NTFSSecurity

Cmdlet Remove-Item2 4.2.6 NTFSSecurity

Cmdlet Remove-NTFSAccess 4.2.6 NTFSSecurity

Cmdlet Remove-NTFSAudit 4.2.6 NTFSSecurity

Cmdlet Set-NTFSInheritance 4.2.6 NTFSSecurity

Cmdlet Set-NTFSOwner 4.2.6 NTFSSecurity

Cmdlet Set-NTFSSecurityDescriptor 4.2.6 NTFSSecurity

Cmdlet Test-Path2 4.2.6 NTFSSecurity

Conclusion

In this post, we went over the many methods that may be used to install the PowerShell module on Windows. You are now able to select the way that best suits your needs to install the PowerShell module that you want to use to carry out complicated administrative chores using its command-line and script language. The PowerShell program is compatible with all of the major operating systems, including Microsoft Windows, Linux, and Apple Mac OS X.

Leave a Reply