Forum Replies Created
April 27, 2018 at 9:14 am in reply to: Current Processor Architecture is X86. The Module Requires AMD64 – PowerShell #email@example.comParticipant
I am trying to get a web page (an Azure web app) to invite a (guest) user to my Azure Active directory. I know there is the Microsoft Graph API to wrestle with but I was hoping for building on something I knew worked. The architecture error may have to do with my personal computer because it goes away when I publish the web site project and run it ‘in the cloud’; there I get ‘the AzureAD module can’t be found’ and similar failure of the two AzureAD cmdlets I show below so I am now digging around on how Azure web apps find PowerShell modules … it is always something (e.g., the web app needed to Import-AzureRM.Profile instead of Import-AzureRM for the Login-AzureRMAccount cmdlet to work but, alas, no similar find yet for the AzureAD module in an Azure web app)
But if you can help me clear up my local issue for dev & test, that would helpful. This script works great from PowerShell or running the script from the command-line:
$u = ‘Azure UID’;
$p = ConvertTo-SecureString -AsPlainText ‘Azure Password’ -Force;
$cred = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $u, $p;
Login-AzureRmAccount -Credential $cred;
Connect-AzureAD -Credential $cred;
$ADGuest = New-AzureADMSInvitation -SendInvitationMessage $true `
-InviteRedirectUrl ‘Landing page when they accept invite’ `
-InvitedUserDisplayName ‘Their name’ `
-InvitedUserEmailAddress ‘Their email’;
but when I try to run this script using the following C# code (note that psSendInvite key in AppSettings has as its value the PowerShell Script and the PowerShell object is in System.Management.Automation)
PowerShell ps = PowerShell.Create();
I get four results in the error stream
The current processor architecture is: X86. The module ‘C:\Program Files\WindowsPowerShell\Modules\AzureAD\22.214.171.124\AzureAD.psd1’ requires the following architecture: Amd64.
Exception has been thrown by the target of an invocation.
The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The term ‘New-AzureADMSInvitation’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I found a web page suggesting that changing a line in the referenced AzureAD.psd1 would help (e.g., see https://stackoverflow.com/questions/24009803/error-running-powershell-script-from-c-sharp) but that fouled up my build in Visual Studio (my guess is some checksum went wrong with that change).
So a bit long but ironing this out would be very productive for some of my plans; thanks for taking a look!April 27, 2018 at 3:05 am in reply to: Current Processor Architecture is X86. The Module Requires AMD64 – PowerShell #firstname.lastname@example.orgParticipant
What if the PowerShell is running in a .Net System.Managment.Automation.PowerShell object? That is, it is only indirectly PowerShell, not the console or ise. Any guidance helpful