Form1 is simply an empty form. In Executable Properties the platform is set to x64.
When running this project in Visual Studio 2019 everything is fine. Output is “64Bit” and Import-Module is working as expected.
When packaging this script and running the resulting .exe from the Powershell console I am getting the following result:
Import-Module : Die aktuelle Prozessorarchitektur ist: X86. Für das Modul "C:\Program
Files\WindowsPowerShell\Modules\AzureAD\2.0.2.61\AzureAD.psd1" ist die folgende Prozessorarchitektur erforderlich:
Amd64.
In Zeile:2 Zeichen:1
+ Import-Module -Name AzureAD
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (C:\Program File...61\AzureAD.psd1:String) [Import-Module], Invalid
OperationException
+ FullyQualifiedErrorId : Modules_InvalidProcessorArchitecture,Microsoft.PowerShell.Commands.ImportModuleCommand
32Bit
Packaging the script in Visual Studio Code produces the same error.
I found that I could package by right clicking on the script in Visual Studio 2019. Then the executable is running as x64 process. But then I am not able to hide the console window which is essential for this project.
Sorry for the necro, but it seems I’m having the exact same issue.
Platform is set to x64 in Visual Studio but I’m getting the same error
Error while import module: System.InvalidOperationException: The current processor architecture is: X86. The module ‘C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.2.128\AzureAD.psd1’ requires the following architecture: Amd64.
Hmmm could be. The process check is actually done by PowerShell and the AzureAD module is just including the ProcessorArchitecture check in it’s module. I did look at the PS source code and this is how they are checking processor architecture. Not with IntPtr.
Created a new Powershell Forms project and input just your lines.
Result is Amd64 in the console output but still the AzureAD module is failing.
Do I need to change anything in the Configuration Manager? It’s currently set to Any CPU (sorry if it’s a dumb question but I’m still kinda new to this)