0
0
PowerShellscripting~15 mins

Importing modules in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Importing modules
📖 Scenario: You are writing a PowerShell script to use extra commands that are not built-in. These commands come from a module. You want to learn how to bring that module into your script so you can use its commands.
🎯 Goal: Learn how to import a PowerShell module called Microsoft.PowerShell.Utility and then use a command from it.
📋 What You'll Learn
Create a variable with the module name
Import the module using the variable
Use a command from the imported module
Print the result of the command
💡 Why This Matters
🌍 Real World
PowerShell modules add extra commands that help automate tasks. Importing modules lets you use these commands in your scripts.
💼 Career
Many IT and automation jobs require using PowerShell modules to manage systems and automate workflows efficiently.
Progress0 / 4 steps
1
Create a variable with the module name
Create a variable called $moduleName and set it to the string 'Microsoft.PowerShell.Utility'.
PowerShell
Need a hint?

Use = to assign the string to the variable.

2
Import the module using the variable
Use the Import-Module command with the variable $moduleName to import the module.
PowerShell
Need a hint?

Write Import-Module $moduleName to load the module.

3
Use a command from the imported module
Use the Get-Random command to get a random number between 1 and 10 and save it in a variable called $randomNumber.
PowerShell
Need a hint?

Use Get-Random -Minimum 1 -Maximum 11 to get a number from 1 to 10.

4
Print the result
Print the value of the variable $randomNumber using Write-Output.
PowerShell
Need a hint?

Use Write-Output $randomNumber to show the number.