d365collaborative / d365fo.tools

Tools used for Dynamics 365 Finance and Operations
MIT License
250 stars 102 forks source link

Install fails - clash with Az module #563

Closed mpburtt closed 3 years ago

mpburtt commented 3 years ago

Running install-module -name d365fo.tools, it runs for a bit then falls over with the following error:

`PackageManagement\Install-Package : The following commands are already available on this system:'Login-AzAccount,Logout-AzAccount,Resolve-Error,Send-Feedback'. This module 'AzureRM.Profile' may override the existing commands. If you still want to install this module 'AzureRM.Profile', use -AllowClobber parameter. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.4.1\PSModule.psm1:9709 char:34

That seems to be a clash with the standard Az admin module. Anyone got any clues on how to get past that without clobbering the existing module?

Splaxi commented 3 years ago

I would argue that the installation order might be reversed and it should work.

mpburtt commented 3 years ago

Are you saying that I should uninstall the Az module, install d365fotools and then re-install Az?

Splaxi commented 3 years ago

Something like that.

The case is that when the project started WAAAAAAAAY back, we couldn't expect the latest and greatest .net versions to be available, so we had to stick with some of the legacy powershell modules.

But as with many things, Microsoft did refactor while release the latest version of some powershell modules, which blocks the legacy ones. But I actually found a trick, in one of the other issues here - on how to load things in the correct order, to avoid the blocking note and things seems to work as the should.

But I would also say that most Powershell people are used to -AllowClobber, and just learns what modules can be loaded in the same session.

Splaxi commented 3 years ago

The import order will allow you to load modules, that normally states they can't be loaded:

https://github.com/d365collaborative/d365fo.tools/issues/361

Splaxi commented 3 years ago

Should we try to test for a way to solve your issue?

mpburtt commented 3 years ago

Absolutely. Happy to try anything

Splaxi commented 3 years ago

Could you list all the modules that you need installed, for me to do some testing with?

Could you share some of the scripts - cmdlets, from Az.* modules that you're depending on?

mpburtt commented 3 years ago

I use a whole bunch of Az cmdlets (as a former Unix guy, I'll try to automate anything that I find I have to do more than once but that probably means my head is still living Perl & awk despite the 20+ years since I moved off Unix), most recently in the area of creating Azure Alerts for logic app execution failures

In the end, I've just gone ahead and done...

install-module -name d365fo.tools -AllowClobber install-module Az -AllowClobber

which allowed the install to complete.

You're probably right - I should get used to the idea of AllowClobber, I just don't recall needing to do it until now.

Splaxi commented 3 years ago

I always think of it like this.

If AllowClobber is a core parameter while installing new modules, it is a expected behavior that you encounter conflicts between modules.

Next issue is that you might have to disable auto load of modules, but that is easy fixed.

Splaxi commented 3 years ago

Let me know if you need anything else.