1
votes

I am trying to debug a powershell script in Visual Studio Code but when I try to execute connect-azuread I get this error message:

connect-azuread : The 'connect-azuread' command was found in the module 'AzureAD', but the module could not be loaded. For more information, run 'Import-Module AzureAD'.

When I try to do Import-Module AzureAD, I get this other error:

Import-Module : The current processor architecture is: X86. The module 'C:\Program Files\WindowsPowerShell\Modules\azuread\2.0.2.4\azuread.psd1' requires the following architecture: Amd64.

If I switch the terminal from PowerShell Integrated to powershell it works, but when I start debugging my code it goes back to the integrated one.

Any ideas how to fix this?

2
Are you sure that you installed the 64 bit version of Visual Studio Code? I am not able to replicate the issue, though I am admittedly using AzureAD v2.0.2.26, which is what installed by default from Find-Module -Name AzureAD | Install-Module.TheMadTechnician
Yes, I even uninstalled and reinstalled CodePaolo Barone

2 Answers

0
votes

In the meantime it looks like I managed to fix this by updating the settings to this:

{
"powershell.powerShellExePath": 
    "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "terminal.integrated.shell.windows": 
    "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "terminal.explorerKind": "external"
}

The original version was below and it looks like the SysWow64 version is 32 bit

{
    "powershell.powerShellExePath": "C:\\WINDOWS\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}
0
votes

Remove the (x86) from the powershell.powerShellDefaultVersion setting in VS settings.