Windows PowerShell is a cross-platform task automation solution that is designed with an interactive command-line shell capable of simplifying configurations while also automating administrative tasks. Microsoft created Windows PowerShell to automate and control the administration tasks run on the Windows Server Environment.
Among Windows users and system administrators, this tool has become very popular. It can be used to automate any task in the Windows ecosystem. There is a new version that ensures that administrators can manage Windows server OS and control Lync-based servers, Exchange, and SQL. A PowerShell contains a scripting language, a command-line shell, and a configuration management framework that facilitates script automation, batching processing, and control of resources in the cloud.
In addition, the use of Windows Powershell allows many functions. It also supports the implementation of a .net code. Further, several versions of Windows Powershell are simple to learn and execute.
Components and Types of PowerShell Module
A module consists of four essential components. These include a PowerShell script or a managed cmdlet assembly, a manifest file, additional assemblies or scripts, and a directory containing all the content. This section will share more details about the different types of modules.
- Script Modules This is a Windows PowerShell script that has a .psm1 extension. It ensures that administrators can use import, export, and management functions. A script module also comes with a valid Windows PowerShell code. This can be installed or saved on the PowerShell module path.
- Binary Modules These are .net framework assemblies that are designed with compiled code. Concerning a script module, a binary module ensures that users can create cmdlets faster. It can also allow using several features, such as multithreading, which are more challenging to code in Windows PowerShell scripts. Furthermore, a binary module can be saved or installed in a folder along the PowerShell module path.
- Manifest Modules These modules use a manifest file to describe all of their component binary modules but do not have any core assembly or script.
- Dynamic Modules This module is not loaded from or saved to a file. Instead, as their name implies, they are created dynamically by a script, using the New-Module cmdlet. This module ensures that a script can create a module on demand and does not need to be loaded or saved to any persistent storage. With this in mind, these modules require no permanent folders to store their related assemblies.
Installing a PowerShell Module
After creating a module, the next thing is to save your work in a location where Windows PowerShell is installed. Others may also be granted access to it. Before making use of a module, it is important to install the module first. Besides this, you must also find the PowerShell commands that are added by the module by making use of the cmdlet Get-Command, and lastly, you need to use the commands that the module added. Two methods are available for installing PowerShell Module, which are discussed in the following section.
Install PowerShell Modules Manually
If the needed module is unavailable in the PowerShell gallery, then you can proceed to install the PowerShell module manually. The following steps can help you install the PowerShell module manually.
The first step is to open PowerShell as an administrator user. Then, find the default installation path of the PowerShell module by making use of the following command:
$Env:PSModulePath
Then, the next step is to download the PowerShell module named Powernet from the internet while copying it into the PowerShell default path:
Verify the Powernet module.
After this, you can run the following command to verify the newly added module visible to PowerShell:
Get-Module -ListAvailable
The newly added Powernet module should be present in the following output:
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIP…
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchT…
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protoc…
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Re…
Manifest 1.0.0.0 NetworkSwitchManager {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitch…
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConf…
Manifest 1.0 NFS {Get-NfsMappedIdentity, Get-NfsNetgroup, Install-NfsMapp…
Script 0.0 PowerNet {Test-TCPPort, Enable-Monitoring, Disable-Monitoring, Writ…
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Rest…
Binary 1.0.0.0 PersistentMemory {Get-PmemDisk, Get-PmemPhysicalDevice, Get-PmemUnusedReg…
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServer, Export-Certifica…
Manifest 1.0.0.0 PlatformIdentifier Get-PlatformIdentifier
Manifest 1.0.0.0 PnpDevice {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice,…
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-Pr…
Binary 1.0.11 ProcessMitigations {Get-ProcessMitigation, Set-ProcessMitigation, ConvertTo…
Manifest 1.1 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguratio…
After this, proceed to load the added module to the active memory. It will allow you to access it in your current session:
Import-Module -Name PowerNet
You will get the following warning message:
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 and press the Enter key to load the module. You will get another error message:
import-module: File C:\Program Files\WindowsPowerShell\Modules\PowerNet\PowerNet.psm1 cannot be loaded because running scripts are disabled on this system.
To resolve this error, you must set the execution policy unrestricted. You can set it with the following command:
Set-ExecutionPolicy Unrestricted
Install PowerShell Module From PowerShell Gallery
This represents the easiest method that can help you install the PowerShell module. The following steps should be followed to install the PowerShell module from the PowerShell gallery.
The first action is installing the Nuget package on your system. You can achieve this by running the following command:
Install-PackageProvider Nuget –Force
After this is installed, the following output will appear:
Name Version Source Summary
—- ——- —— ——-
nuget 2.8.5.208 https://onege… NuGet provider for the OneGet meta-package manager
After this, the next step is to install the PowerShellGet on your system. PowerShellGet is a module that offers commands to find, update and publish modules. This can be installed with the following command:
Install-Module –Name PowerShellGet –Force
Then, the next step is to install the module named NTFSSecurity from the PowerShell gallery by making use of 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.
Detailed information about the installed module will be displayed when you run 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
Using ManageEngine ADManager Plus – FREE TRIAL
If PowerShell feels too complicated, you can achieve all that PowerShell scripts can do through ManageEngine ADManager Plus. You can automate AD creation, cleanup, user provisioning and deprovisioning, set time limits, and more, through an intuitive user interface. ADManager Plus is a unified AD and M365 management and reporting platform that can improve security and compliance across your entire environment through automation.
Download this tool for a 30-day free trial.
Conclusion
With PowerShell, users can manage the automation of their systems. In this guide, we have provided an insight into the different types and components of a PowerShell module, as well as what makes them unique. More importantly, the methods of installing the PowerShell module have been discussed above.