Concept Flow - AD module installation
Start
Check if AD module is installed
Import
Import AD module
End
The script checks if the Active Directory module is installed. If not, it installs it, then imports the module for use.
if (-not (Get-Module -ListAvailable -Name ActiveDirectory)) {
Install-WindowsFeature -Name RSAT-AD-PowerShell
}
Import-Module ActiveDirectory
Get-Module ActiveDirectory| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Check if AD module is available | Get-Module -ListAvailable -Name ActiveDirectory | False (module not found) |
| 2 | Install AD module | Install-WindowsFeature -Name RSAT-AD-PowerShell | Success (module installed) |
| 3 | Import AD module | Import-Module ActiveDirectory | Module imported |
| 4 | Verify import | Get-Module ActiveDirectory | ActiveDirectory module listed |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| ADModuleAvailable | null | False | False | True | True |
Check if AD module exists with Get-Module -ListAvailable. If missing, install with Install-WindowsFeature RSAT-AD-PowerShell. Import module using Import-Module ActiveDirectory. Verify import with Get-Module ActiveDirectory. This ensures AD cmdlets are ready to use.