PowerShell/vscode-powershell

PnP Powershell throws 0x80131621 error in VS Code

all2001 opened this issue · 1 comments

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

VS Code Version - 1.84.0-insider (also tried with 1.83.1)
VS Code Powershell Extension - v2023.8.0
Powershell version - 7.3.8
PnP.Powershell module version - 2.2

I have a script that has the following:
Connect-PnPOnline -Url -ClientId -Tenant <tenant-id>
-Thumbprint

Connect-MicrosoftTeams -TenantId <tenant-id> `
    -CertificateThumbprint <cert-thumbprint> `
    -ApplicationId <app-id2>

Connect-MgGraph -ClientId <app-id3> -TenantId <tenant-id> -CertificateThumbprint <cert-thumbprint>

This script fails on the first command with the following error:
Connect-PnPOnline: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.50.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Could not find or load a specific file. (0x80131621)

This issue is in VS Code only, when I do the same in native Powershell terminal - it works fine.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.84.0-insider
c42f8961f9ba803175ccbb8260e8d70d561f8bee
x64

also tried with 1.83.1 with the same result

Extension Version

ms-vscode.powershell@2023.8.0

Steps to Reproduce

VS Code Version - 1.84.0-insider (also tried with 1.83.1)
VS Code Powershell Extension - v2023.8.0
Powershell version - 7.3.8
PnP.Powershell module version - 2.2

I have a script that has the following:

Connect-PnPOnline -Url  <spo-site> -ClientId <app-id> `
    -Tenant <tenant-id> `
    -Thumbprint <cert-thumbprint>

Connect-MicrosoftTeams -TenantId <tenant-id> `
    -CertificateThumbprint <cert-thumbprint> `
    -ApplicationId <app-id2>

Connect-MgGraph -ClientId <app-id3> -TenantId <tenant-id> -CertificateThumbprint <cert-thumbprint>

This script fails on the first command with the following error:
Connect-PnPOnline: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.50.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Could not find or load a specific file. (0x80131621)

This issue is in VS Code only, when I do the same in native Powershell terminal - it works fine.

Visuals

image

Logs

No response

Please see the pinned issue and ask the PnP.PowerShell devs to fix their module: #3510 In short, they isolated a couple dependencies but not all their dependencies, which causes Microsoft.Identity.Client to conflict with many other modules like ExchangeOnline etc.)