0
0
PowerShellscripting~15 mins

AD module installation in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
AD module installation
📖 Scenario: You are setting up a Windows system to manage Active Directory (AD) users and computers. To do this, you need to install the Active Directory module for PowerShell.
🎯 Goal: Learn how to check if the Active Directory module is installed, install it if missing, and import it to use AD commands.
📋 What You'll Learn
Create a variable to check if the Active Directory module is installed
Create a variable to hold the module name 'ActiveDirectory'
Use an if statement to install the module if it is not installed
Import the Active Directory module
Print a message confirming the module is ready
💡 Why This Matters
🌍 Real World
System administrators often need to manage Active Directory using PowerShell. Installing and importing the AD module is the first step to automate user and computer management.
💼 Career
Knowing how to install and use PowerShell modules like Active Directory is essential for IT professionals working in Windows server environments and network administration.
Progress0 / 4 steps
1
Check if the Active Directory module is installed
Create a variable called moduleName and set it to the string 'ActiveDirectory'. Then create a variable called moduleInstalled that uses Get-Module -ListAvailable -Name $moduleName to check if the module is available.
PowerShell
Need a hint?

Use Get-Module -ListAvailable -Name $moduleName to find if the module exists on the system.

2
Prepare to install the module if missing
Create a variable called installModuleName and set it to the string 'RSAT.ActiveDirectory.DS-LDS.Tools', which is the package name for the AD module installation on Windows 10/11.
PowerShell
Need a hint?

This is the exact package name to install the AD module on recent Windows versions.

3
Install the Active Directory module if it is not installed
Write an if statement that checks if $moduleInstalled is empty or null. If it is, run Add-WindowsCapability -Online -Name $installModuleName to install the module.
PowerShell
Need a hint?

Use -not $moduleInstalled to check if the module is missing.

4
Import the module and confirm installation
Import the Active Directory module using Import-Module $moduleName. Then print 'Active Directory module is ready.' using Write-Output.
PowerShell
Need a hint?

Use Import-Module $moduleName to load the module, then Write-Output to print the message.