Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with the .Net dll of the Az module #3012

Closed
sgiovinetti opened this issue Oct 15, 2020 · 22 comments
Closed

Conflict with the .Net dll of the Az module #3012

sgiovinetti opened this issue Oct 15, 2020 · 22 comments
Labels
Resolution-Inactive Will close automatically.

Comments

@sgiovinetti
Copy link

sgiovinetti commented Oct 15, 2020

If I run with extension enabled this code (and a lot of others Az commands):
Connect-AzAccount I receive the following error:

Connect-AzAccount: The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'.

Running the same code without the extension works perfectly. I guess this extension reference some .NET libraries that goes in conflict with the .NET libraries used in Az.Accounts module

Here the modules i have installed:

Get-Module -ListAvailable

    Directory: C:\Program Files\PowerShell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               CimCmdlets                          Core      {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession…}
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
Manifest   7.0.0.0               Microsoft.PowerShell.Diagnostics    Core      {Get-WinEvent, New-WinEvent, Get-Counter}
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Get-Clipboard, Set-Clipboard…}
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential…}
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
Manifest   7.0.0.0               Microsoft.WSMan.Management          Core      {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig…}
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     2.0.5                 PSDesiredStateConfiguration         Core      {Configuration, New-DscChecksum, Get-DscResource, Invoke-DscResource}
Script     7.0.0.0               PSDiagnostics                       Core      {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace…}
Script     2.0.2                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLineOption…}
Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob

    Directory: C:\Users\giost\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     4.7.0                 Az                                  Core,Desk
Script     1.9.4                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection, Enable-AzContextAutosave…}
Script     1.1.1                 Az.Advisor                          Core,Desk {Get-AzAdvisorRecommendation, Enable-AzAdvisorRecommendation, Disable-AzAdvisorRecommendation, Get-AzAdvisorConfiguration…}
Script     1.3.0                 Az.Aks                              Core,Desk {Get-AzAksCluster, New-AzAksCluster, Remove-AzAksCluster, Import-AzAksCredential…}
Script     1.1.4                 Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServer, Get-AzAnalysisServicesServer, Remove-AzAnalysisServicesServer…}
Script     2.1.0                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagementProductToGroup, Add-AzApiManagementRegion…}
Script     1.1.0                 Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzApplicationInsights, Remove-AzApplicationInsights, Update-AzApplicationInsights…}
Script     1.4.0                 Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWorkerGroup, Get-AzAutomationJobOutputRecord, Import-AzAutomationDscNodeConfiguration…}
Script     3.1.0                 Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAccountKey, New-AzBatchAccount…}
Script     1.0.3                 Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollmentAccount, Get-AzConsumptionBudget…}
Script     1.4.3                 Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile, Remove-AzCdnProfile…}
Script     1.6.0                 Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAccountKey, Get-AzCognitiveServicesAccountSku, Get-AzCognitiveServicesAccountType…}
Script     4.4.0                 Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabilitySet, Update-AzAvailabilitySet…}
Script     1.0.3                 Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzContainerGroup, Get-AzContainerInstanceLog}
Script     1.1.1                 Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistry, Update-AzContainerRegistry, Remove-AzContainerRegistry…}
Script     1.1.0                 Az.DataBoxEdge                      Core,Desk {Get-AzDataBoxEdgeJob, Get-AzDataBoxEdgeDevice, Invoke-AzDataBoxEdgeDevice, New-AzDataBoxEdgeDevice…}
Script     1.10.1                Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFactoryV2, Remove-AzDataFactoryV2…}
Script     1.0.2                 Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalyticsCatalogCredential, Remove-AzDataLakeAnalyticsCatalogCredential, Set-AzDataLakeAnalyticsCatalogCredential…}
Script     1.2.8                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreFirewallRule, Set-AzDataLakeStoreTrustedIdProvider…}
Script     1.0.0                 Az.DataShare                        Core,Desk {New-AzDataShareAccount, Get-AzDataShareAccount, Remove-AzDataShareAccount, New-AzDataShare…}
Script     1.1.0                 Az.DeploymentManager                Core,Desk {Get-AzDeploymentManagerArtifactSource, New-AzDeploymentManagerArtifactSource, Set-AzDeploymentManagerArtifactSource, Remove-AzDeploymentManagerArtifactSource…}
Script     1.0.0                 Az.DesktopVirtualization            Core,Desk {Disconnect-AzWvdUserSession, Get-AzWvdApplication, Get-AzWvdApplicationGroup, Get-AzWvdDesktop…}
Script     1.0.2                 Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolicy, Get-AzDtlAutoStartPolicy, Get-AzDtlVMsPerLabPolicy…}
Script     1.1.2                 Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRecordSet, Set-AzDnsRecordSet…}
Script     1.3.0                 Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGridTopic, New-AzEventGridTopicKey…}
Script     1.6.0                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHubNamespace, Remove-AzEventHubNamespace…}
Script     1.6.1                 Az.FrontDoor                        Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-AzFrontDoor, Remove-AzFrontDoor…}
Script     1.0.2                 Az.Functions                        Core,Desk {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Get-AzFunctionAppPlan, Get-AzFunctionAppSetting…}
Script     3.6.0                 Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wait-AzHDInsightJob, New-AzHDInsightStreamingMapReduceJobDefinition…}
Script     1.1.0                 Az.HealthcareApis                   Core,Desk {New-AzHealthcareApisService, Remove-AzHealthcareApisService, Set-AzHealthcareApisService, Get-AzHealthcareApisService}
Script     2.5.0                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-AzIotHubConnectionString, Get-AzIotHubJob…}
Script     2.2.0                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-AzKeyVaultCertificateOperation, Get-AzKeyVaultCertificateOperation…}
Script     1.0.0                 Az.Kusto                            Core,Desk {Add-AzKustoClusterLanguageExtension, Add-AzKustoDatabasePrincipal, Get-AzKustoAttachedDatabaseConfiguration, Get-AzKustoCluster…}
Script     1.3.2                 Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountAssembly, Get-AzIntegrationAccountBatchConfiguration, Get-AzIntegrationAccountCallbackUrl…}
Script     1.1.3                 Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssociation, Get-AzMlCommitmentPlanUsageHistory, Remove-AzMlCommitmentPlan…}
Script     1.1.0                 Az.Maintenance                      Core,Desk {Get-AzApplyUpdate, Get-AzConfigurationAssignment, Get-AzMaintenanceConfiguration, Get-AzMaintenanceUpdate…}
Script     1.1.0                 Az.ManagedServices                  Core,Desk {Get-AzManagedServicesAssignment, New-AzManagedServicesAssignment, Remove-AzManagedServicesAssignment, Get-AzManagedServicesDefinition…}
Script     1.0.2                 Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.1.1                 Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzMediaServiceKey, Get-AzMediaServiceKey, Get-AzMediaServiceNameAvailability…}
Script     2.1.0                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-AzLogProfile…}
Script     3.4.0                 Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplicationGatewayAuthenticationCertificate, New-AzApplicationGatewayAuthenticationCertificate, Remove-AzApplicationGatewayAuthenticationCertificate…}
Script     1.1.1                 Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAuthorizationRule, Get-AzNotificationHubListKey, Get-AzNotificationHubPNSCredential…}
Script     2.3.0                 Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOperationalInsightsCustomLogDataSource, Disable-AzOperationalInsightsLinuxCustomLogCollection, Disable-AzOperationalInsightsIISLogCollection…}
Script     1.3.1                 Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSummary, Get-AzPolicyRemediation…}
Script     1.1.2                 Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspaceCollectionAccessKey, Get-AzPowerBIWorkspace…}
Script     1.0.3                 Az.PrivateDns                       Core,Desk {Get-AzPrivateDnsZone, Remove-AzPrivateDnsZone, Set-AzPrivateDnsZone, New-AzPrivateDnsZone…}
Script     2.12.1                Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVault, Get-AzRecoveryServicesVaultSettingsFile, New-AzRecoveryServicesVault…}
Script     1.2.1                 Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheScheduleEntry, Get-AzRedisCachePatchSchedule, New-AzRedisCachePatchSchedule…}
Script     1.0.3                 Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNamespace, Remove-AzRelayNamespace…}
Script     2.5.1                 Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, New-AzRoleAssignment…}
Script     1.4.1                 Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set-AzServiceBusNamespace, Remove-AzServiceBusNamespace…}
Script     2.2.0                 Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricClientCertificate, Add-AzServiceFabricClusterCertificate, Add-AzServiceFabricNode, Add-AzServiceFabricNodeType…}
Script     1.2.0                 Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSignalRKey…}
Script     2.10.0                Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTransparentDataEncryptionActivity, Set-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseUpgradeHint…}
Script     1.1.0                 Az.SqlVirtualMachine                Core,Desk {New-AzSqlVM, Get-AzSqlVM, Update-AzSqlVM, Remove-AzSqlVM…}
Script     2.6.0                 Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAccount, New-AzStorageAccountKey…}
Script     1.3.0                 Az.StorageSync                      Core,Desk {Invoke-AzStorageSyncCompatibilityCheck, New-AzStorageSyncService, Get-AzStorageSyncService, Set-AzStorageSyncService…}
Script     1.0.1                 Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefaultFunctionDefinition, New-AzStreamAnalyticsFunction, Remove-AzStreamAnalyticsFunction…}
Script     1.0.0                 Az.Support                          Core,Desk {Get-AzSupportService, Get-AzSupportProblemClassification, Get-AzSupportTicket, Get-AzSupportTicketCommunication…}
Script     1.0.4                 Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTrafficManagerCustomHeaderFromEndpoint, Add-AzTrafficManagerCustomHeaderToProfile, Remove-AzTrafficManagerCustomHeaderFromProfile…}
Script     1.11.0                Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan, Remove-AzAppServicePlan…}
Manifest   1.0.867               MicrosoftPowerBIMgmt                Desk      
Binary     1.0.867               MicrosoftPowerBIMgmt.Admin          Desk      {Add-PowerBIEncryptionKey, Get-PowerBIEncryptionKey, Get-PowerBIWorkspaceEncryptionStatus, Switch-PowerBIEncryptionKey…}
Binary     1.0.867               MicrosoftPowerBIMgmt.Capacities     Desk      Get-PowerBICapacity
Binary     1.0.867               MicrosoftPowerBIMgmt.Data           Desk      {Add-PowerBIDataset, Set-PowerBITable, New-PowerBIDataset, New-PowerBITable…}
Binary     1.0.867               MicrosoftPowerBIMgmt.Profile        Desk      {Connect-PowerBIServiceAccount, Disconnect-PowerBIServiceAccount, Invoke-PowerBIRestMethod, Get-PowerBIAccessToken…}
Binary     1.0.867               MicrosoftPowerBIMgmt.Reports        Desk      {Get-PowerBIReport, New-PowerBIReport, Export-PowerBIReport, Get-PowerBIDashboard…}
Binary     1.0.867               MicrosoftPowerBIMgmt.Workspaces     Desk      {Get-PowerBIWorkspace, Get-PowerBIWorkspaceMigrationStatus, Add-PowerBIWorkspaceUser, Remove-PowerBIWorkspaceUser…}
Script     4.10.1                Pester                              Desk      {Describe, Context, It, Should…}
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script     21.1.18228            SqlServer                           Desk      {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Add-SqlAzureAuthenticationContext…}

    Directory: C:\Users\giost\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.3                 Plaster                             Desk      {Invoke-Plaster, New-PlasterManifest, Get-PlasterTemplate, Test-PlasterManifest}
Binary     2.1.0                 PowerShellEditorServices            Core,Desk Start-EditorServices
Binary     0.2.0                 PowerShellEditorServices.VSCode     Desk      {New-VSCodeHtmlContentView, Show-VSCodeHtmlContentView, Close-VSCodeHtmlContentView, Set-VSCodeHtmlContentView…}
Script     2.0.2                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLineOption…}
Script     1.19.0                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}
@ghost ghost added the Needs: Triage Maintainer attention needed! label Oct 15, 2020
@SeeminglyScience
Copy link
Collaborator

Connect-AzAccount: The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'.

Could you include the output of Import-Module Az.Accounts please

@sgiovinetti
Copy link
Author

sgiovinetti commented Oct 15, 2020

@SeeminglyScience I can do even more :-)

> Import-Module Az.Accounts
>  $Error[0].Exception | fl * -force

Message : Assembly with same name is already loaded FileName : FusionLog : TargetSite : Void Bind_LoadAssemblies(System.Management.Automation.ExecutionContext) StackTrace : at System.Management.Automation.Runspaces.InitialSessionState.Bind_LoadAssemblies(ExecutionContext context) at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, Boolean setLocation) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable1 requiredModuleGuid, ImportModuleOptions& options, Boolean&
containedErrors)
Data : {}
InnerException :
HelpLink :
Source : System.Management.Automation
HResult : -2146232799

@SeeminglyScience
Copy link
Collaborator

Thanks! Can you see if it repros with the latest PowerShell 7.1 preview? That looks like the (fixed) PowerShell bug where it would try to load assemblies unnecessarily because they are listed in the FileList manifest field (some of the at intellisense time autoloading that the extension does can make the bug more frequent).

@sgiovinetti
Copy link
Author

@SeeminglyScience No way, the same also with Powershell 7.1 preview

Repro:
Open visual studio code with PS extension installed.
In the VS Code PS terminal run:
Connect-AzAccount

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 16, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Oct 16, 2020

If you can provide the information requested in the issue template, that would be helpful

@rjmholt rjmholt removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 16, 2020
@sgiovinetti
Copy link
Author

System Details Output

Issue Description

I am experiencing a problem running Az module commands within VS Code powershell terminal

Expected Behaviour

Running the command Connect-AzAccount the message with code number and azure authentication procedure should appear

Actual Behaviour

This error appears

Connect-AzAccount: The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 16, 2020
@SydneyhSmith
Copy link
Collaborator

hmmmm @sgiovinetti did you get the same error manually importing the module with RC-1? Also do you have anything in your PowerShell profile or settings?

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 20, 2020
@sgiovinetti
Copy link
Author

@SydneyhSmith : did you get the same error manually importing the module with RC-1? YES
Also do you have anything in your PowerShell profile or settings? As far as I know I don't. Could you please be more specific? What in particular I need to check and how?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 21, 2020
@SydneyhSmith
Copy link
Collaborator

Thanks @sgiovinetti to get your PowerShell profile you can run psedit $profile in the integrated console to view your settings in VSCode use Ctrl + ,

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 22, 2020
@sgiovinetti
Copy link
Author

sgiovinetti commented Oct 23, 2020

@SydneyhSmith
The result of $profile is the following. Although I search in the full disk and wasn't able to find this file. Pressing Ctrl + in VSCode just zoom in the screen.

$profile 

\PowerShell\Microsoft.VSCode_profile.ps1
psedit $profile

Get-ChildItem: C:\Users\giost\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\Commands\Public\CmdletInterface.ps1:191:9
Line |
 191 |          Get-ChildItem $Paths -File | ForEach-Object {
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'D:\PowerShell\Microsoft.VSCode_profile.ps1' because it does not exist.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 23, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Oct 23, 2020

Try mkdir (Split-Path $profile) and then try creating the profile

@TylerLeonhardt
Copy link
Member

@rjmholt I don't think they need to do that. This proves there's nothing in the profile that could be showing this behavior.
.

@corbob
Copy link
Contributor

corbob commented Oct 23, 2020

I am intrigued by the path not being a full path... That looks like it could cause issues based on what the current working directory is in relation to what drive you're on 😬

Out of curiosity: what does $profile | select * output?

@corbob
Copy link
Contributor

corbob commented Oct 23, 2020

Pressing Ctrl + in VSCode just zoom in the screen.

@sgiovinetti I believe what Sydney was saying was try Ctrl + , to pull up the vscode settings. Once the settings are opened, there should be a button in the top left to "Open Settings (JSON)" that should show you if you have any settings that differ from the defaults.

@sgiovinetti
Copy link
Author

@corbob

$profile | select *

AllUsersAllHosts       : C:\Program Files\PowerShell\7-preview\profile.ps1
AllUsersCurrentHost    : C:\Program Files\PowerShell\7-preview\Microsoft.VSCode_profile.ps1
CurrentUserAllHosts    : \PowerShell\profile.ps1
CurrentUserCurrentHost : \PowerShell\Microsoft.VSCode_profile.ps1
Length                 : 40

I checked the settings.json and there is nothing there about powershell except
"powershell.powerShellDefaultVersion": "PowerShell Preview (x64)",

@corbob
Copy link
Contributor

corbob commented Oct 26, 2020

🤔 it's interesting that your User profiles are missing the Documents directory... The profile is usually stored in the PowerShell directory of: [environment]::GetFolderPath("MyDocuments")

C:\Users\corbob> [environment]::GetFolderPath("MyDocuments")
C:\Users\corbob\OneDrive\Documents
C:\Users\corbob> $profile | select *

AllUsersAllHosts       : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost    : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\corbob\OneDrive\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\corbob\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length                 : 78

Of course this is probably secondary to the originally reported issue...

@sgiovinetti
Copy link
Author

sgiovinetti commented Nov 5, 2020

@corbob : one detail that perhaps could be important. Our IT has setup the laptop so that the windows user settings reside on a mapped drive (NAS) that is not available when we work from home. I notice that when I connect to my company with the VPN and the mapped drive becomes available the vscode powershell intellisense tries to search for libraries on the mapped drive.

I guess the issue is in the vscode extension intellisense, I guess intellisense is trying to load some .net libraries located somewhere on my laptop or on network that goes in conflict with the Az module.

In fact I noticed that randomly, trying to open a fresh vs-code closing all the .ps files tab and opening a brand new empty .ps file sometimes it works.

@rjmholt
Copy link
Contributor

rjmholt commented Nov 10, 2020

So looking at things, it seems like two of the same assembly are somehow being loaded and the first one prevents the second one, which is the one from Az.Accounts, from being loaded.

The big question to my mind is: why and where is the first version of the assembly loaded and where from?

A couple of things that would help us answer that question:

  • Diagnostic logs from the extension, which detail each assembly loaded
  • Any way you have to drill into the error message from Import-Module to get it to tell you which assembly can't be loaded (Get-Error will be good here)

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Nov 10, 2020
@sgiovinetti
Copy link
Author

@rjmholt : the loading error is clearly shown on the third message from the top. The conflicting module is FusionLog.
I guess the conflicting modules are loaded by the VSCode intellisense.

I will work on activating the diagnostic logs extension so I can provide you more details.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 11, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Nov 11, 2020

the loading error is clearly shown on the third message from the top

That's only part of the error I'm afraid. Try Get-Error.

The conflicting module is FusionLog

Actually that's not a module. You can see there's no such module given in gmo -List. Fusion logs are a tool in Windows for viewing .NET Framework assembly binding issues. Given that you're running PS 7, which is on .NET Core 3.1, I don't think they'll help here.

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Nov 12, 2020
@sgiovinetti
Copy link
Author

It looks like removing the obsolete Azure repos extension solved the issue but I will continue to investigate

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 25, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 1, 2020
@ghost
Copy link

ghost commented Dec 16, 2020

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Inactive Will close automatically.
Projects
None yet
Development

No branches or pull requests

6 participants