I'm trying to pull some user information from the cloud following Microsoft's guide on mandatory multifactor authentication with Microsoft Entra, but I'm facing a lot of issues with PowerShell 7. Despite following the instructions, I'm getting errors instead of results, which is really frustrating since this should be a quick task. Here are the steps I've taken:
1. I made sure to run PowerShell 7 as an Administrator and even tried using my domain admin account.
2. Unfortunately, I can't run essential commands like Get-PSRepository, Install-Module, or Get-InstalledModule. I see the auto-complete functionality even though these commands fail, which makes it all the more confusing.
3. I am able to run Get-Module PackageManagement -ListAvailable, so something's clearly awry.
4. The error I'm getting when trying to run commands from step #2 is: 'The term 'Install-Module' is not recognized as a cmdlet...' What is going on? How can I troubleshoot this issue?
4 Answers
It sounds like you're having a rough time! If you're on Windows, PowerShell 7 should have the PowerShellGet module included by default. If 'Install-Module' isn't recognized, then there might be an issue with your installation. Make sure you're not using an older version of Windows since you mentioned you're getting errors. Have you tried checking if your OS is fully updated?
That might make things easier! Sometimes older OS versions can cause compatibility issues.
You mentioned getting no joy with 'Import-Module PowerShellGet'—that could be why you're stuck. Usually, the cmdlet should exist in any standard PowerShell install. You might want to check if the module's path is even where it should be. Compare it against a fresh install on another machine if possible.
I'll check that out! I appreciate the input.
Definitely do that; it saved me once when I had module issues!
From what you've said, it could be that your PowerShell modules are not properly installed. After checking your configs, I suggest manually updating your PowerShellGet and PackageManagement modules. You can do that with your current privileges if you skip the publisher check for the install-module command.
I’ll give that a try and see if it resolves the issue.
Good luck! I’ve had to do that once too. It can fix a lot of unexpected command issues.
When you run PowerShell, check the module path. Run this command: Import-Module PackageManagement and then check for errors. It's crucial to see if there might be an issue with loading that module since many important commands rely on it. If there's a problem, you might not have the PowerShellGet module properly installed or loaded.
I got an error when trying Import-Module PowershellGet. It seems like it's missing. What should I do?
You might need to update or reinstall PowerShellGet. It can usually be fixed by ensuring all modules are updated from the PowerShell Gallery.
Yeah, I just found out my system is getting upgraded to Windows 11 soon, which might help.