-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Steps to reproduce
Call a script or function with #Requires -Modules [module info], while having the the required module installed. I've only tested with the PartnerCenter module, using either of these in my tests:
#Requires -Modules @{ModuleName='PartnerCenter';ModuleVersion='3.0.10'}, Az.Accounts
or
#Requires -Modules PartnerCenter
Both produce the same error when calling the script.
PS C:\Users\MY-USER> .\Documents\GitHub\PowerShell\Connect-PartnerCenterAsSecureApp.ps1
Import-Module: Assembly with same name is already loadedThe script I'm calling is very basic (https://github.com/JeremyTBradshaw/PowerShell/blob/master/Connect-PartnerCenterAsSecureApp.ps1)
Expected behavior
I expect the script to not fail immediately and instead carry on because I have the module that is required already installed, and it shouldn't matter if it is already loaded or not. For this example script, I should get prompted for the values of the mandatory properties whereas my example has omitted using any parameters.
PS C:\Users\MY-USER>.\Documents\GitHub\PowerShell\Connect-PartnerCenterAsSecureApp.ps1
cmdlet Connect-PartnerCenterAsSecureApp.ps1 at command pipeline position 1
Supply values for the following parameters:
CSPTenantId:Actual behavior
PS C:\Users\MY-USER> .\Documents\GitHub\PowerShell\Connect-PartnerCenterAsSecureApp.ps1
Import-Module: Assembly with same name is already loadedEnvironment data
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0