I've been having a tough time trying to install the `ExchangeOnlineManagement` module in PowerShell 7.5.1 after switching to it from PowerShell 5.1, which works just fine for me. When I run the command to install the module: `Install-Module ExchangeOnlineManagement`, I first get an error saying that administrator rights are needed to install modules in the `C:Program FilesWindowsPowerShellModules` directory. After running PowerShell as an administrator, I then encounter another issue: 'NuGet provider is required to continue. Unable to find repository with SourceLocation.' It suggests using the command `Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force` to resolve this, but that fails as well. I've done quite a bit of troubleshooting, like checking if I'm really running as an admin, trying to install it with `-Scope CurrentUser`, and even trying to register the PSGallery, but I still can't get it to work. I'm on Windows 11 Pro with the default shell being PowerShell 7. Any advice on whether this is a PowerShell 7 compatibility issue or if I should stick to 5.1?
4 Answers
Just a heads-up, running `Install-Module ExchangeOnlineManagement` in your PowerShell command prompt uses PowerShell 5.1 by default if prefixed with `powershell`. You'll also need to run it as an administrator for installations that target all users. If you're still facing issues, consider switching to the MSI or winget version instead of the Windows Store version, as the latter can have some compatibility quirks.
Make sure you aren't putting `powershell` at the start of your command when trying to install the module. That would actually cause it to run in PowerShell 5.1 instead of 7. Just use `Install-Module ExchangeOnlineManagement` directly in PowerShell 7, and it should work! I replicated the issue by starting with `powershell`, so that could definitely be the problem.
Your post is incredibly well-structured! Though I don’t have a direct solution, I genuinely appreciate how clearly you've laid out your issue with code blocks and troubleshooting steps. It's the kind of clarity we need more of in these forums!
Also, if you’re still having the NuGet repository issues, it can sometimes help to check your `$env:PSModulePath -split ';'`. Make sure it includes the correct paths.
You might want to try downloading the module manually and then using your admin account to install it. This is a workaround I use for systems that don’t have internet access, and it often resolves similar issues.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String