Last Updated on August 7, 2025 by Arnav Sharma
Here’s a quick fix if you see the modules installed in the system, but the commands don’t work.
Step 1: Run the get module command and and copy the locations (can be 2 or more)
Get-Module -ListAvailable

Scroll down to look for more locations.
Step 2: Run the following command to see if path(s) from step 1 are missing here
$Env:PSModulePath
[Environment]::GetEnvironmentVariable("PSModulePath")
Step 3: If the location(s) in Step 1 are missing in the output of Step 2, then add the locations using the below script:
#Save the current value in the $p variable.
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
#Add the new path to the $p variable. Begin with a semi-colon separator.
$p += ";C:Program Files (x86)MyCompanyModules" ## Update path here
#Add the paths in $p to the PSModulePath value.
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
Step 4: Reboot the system and check if the path has been added.
To check if all paths are up-to-date and being used by PowerShell, run the below script and any missing paths will be reported in Red Colour (Green outputs are good)
# Step 1: Get all available modules and their directory paths
$modules = Get-Module -ListAvailable | Select-Object Name, ModuleBase
# Step 2: Get the list of directories in $env:PSModulePath
$modulePaths = $env:PSModulePath -split ";" # Splitting the paths
$missingPaths = @()
foreach ($module in $modules) {
# Extract the parent directory path until "Modules"
$moduleParentPath = Split-Path $module.ModuleBase -Parent
# Ensure $moduleParentPath is not empty to avoid the error
while ($moduleParentPath -and (Split-Path $moduleParentPath -Leaf) -ne 'Modules') {
$moduleParentPath = Split-Path $moduleParentPath -Parent
}
# Check if the parent directory is present in $env:PSModulePath
if ($moduleParentPath -and -not ($modulePaths -contains $moduleParentPath)) {
Write-Host "$($module.Name) module directory ($($module.ModuleBase)) is missing from $env:PSModulePath." -ForegroundColor Red
# Add the missing path to the list if not already present
if (-not ($missingPaths -contains $moduleParentPath)) {
$missingPaths += $moduleParentPath
}
}
}
# If there are missing paths, prompt the user to fix
if ($missingPaths.Count -gt 0) {
$action = Read-Host "There are missing paths. Do you want to 'Fix' or 'Ignore'?"
if ($action -eq 'Fix') {
foreach ($path in $missingPaths) {
$env:PSModulePath += ";$path"
}
Write-Host "Paths added to $env:PSModulePath for this session." -ForegroundColor Green
} elseif ($action -eq 'Ignore') {
Write-Host "Ignoring missing paths." -ForegroundColor Yellow
} else {
Write-Host "Invalid choice. Exiting without action." -ForegroundColor Yellow
}
} else {
Write-Host "All module paths are up to date." -ForegroundColor Green
}
And don’t forget to keep your modules updated: Remove Old PowerShell Modules (arnav.au)
I help organisations secure their cloud infrastructure and stay ahead of evolving cyber threats. Microsoft MVP and Certified Trainer, author of Mastering Azure Security, and founder of arnav.au — a platform for practical Cloud, Cybersecurity, DevOps and AI content.
Frequently Asked Questions
This typically happens when the module locations are not included in your PSModulePath environment variable. Even though the modules exist on your system, PowerShell cannot find them because it doesn't know where to look. You can verify this by comparing the locations from Get-Module -ListAvailable with your PSModulePath variable.
Run Get-Module -ListAvailable to see where your modules are located, then run $Env:PSModulePath or [Environment]::GetEnvironmentVariable("PSModulePath") to view the paths PowerShell searches. Compare the two outputs—if the module locations aren't listed in PSModulePath, they're missing and need to be added.
Use the provided script to save your current PSModulePath to a variable, append the new module path with a semicolon separator, and then update the environment variable using [Environment]::SetEnvironmentVariable(). Remember to replace the example path with your actual module directory and reboot your system for the changes to take effect.
Yes, you should reboot your system after adding a new path to PSModulePath to ensure PowerShell recognizes the change. After restarting, you can verify the path was added correctly by running the PSModulePath check command again.
Run the provided diagnostic script that compares all available modules with your PSModulePath variable. The script will display missing paths in red and show a green confirmation if all paths are up to date, and it can even automatically fix missing paths if you choose the 'Fix' option.