0
0
PowerShellscripting~5 mins

Importing modules in PowerShell

Choose your learning style9 modes available
Introduction
Importing modules lets you use extra commands and features that are not built into PowerShell by default.
You want to use special commands for managing files or system settings.
You need to run scripts that require extra tools or functions.
You want to organize your scripts by loading only the parts you need.
You want to share useful commands with others by packaging them in modules.
Syntax
PowerShell
Import-Module -Name ModuleName
Replace ModuleName with the name of the module you want to use.
If the module is installed, PowerShell loads its commands for you.
Examples
Loads the built-in module for managing files and folders.
PowerShell
Import-Module -Name Microsoft.PowerShell.Management
Loads the Azure module to manage cloud resources.
PowerShell
Import-Module -Name Az
Loads the testing module to run script tests.
PowerShell
Import-Module -Name Pester
Sample Program
This script imports the Utility module and lists all commands it provides.
PowerShell
Import-Module -Name Microsoft.PowerShell.Utility
Get-Command -Module Microsoft.PowerShell.Utility
OutputSuccess
Important Notes
If the module is not installed, you may need to install it first using Install-Module.
You can import multiple modules by running Import-Module multiple times.
Use Get-Module -ListAvailable to see all modules you can import.
Summary
Importing modules adds new commands to your PowerShell session.
Use Import-Module with the module name to load it.
Modules help you organize and reuse useful commands.