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

Love this but the powershell for adding the CA is broken #54264

Closed
RescueWhale opened this issue May 6, 2020 — with docs.microsoft.com · 5 comments
Closed

Love this but the powershell for adding the CA is broken #54264

RescueWhale opened this issue May 6, 2020 — with docs.microsoft.com · 5 comments

Comments

Copy link

Get the following, tried multiple PCs with different global admins, not sure what else it could be other than broken or the wrong command is listed above.

New-MgServicePrincipal : Could not load file or assembly 'Microsoft.Graph.Authentication, Version=0.2.0.0,
Culture=neutral, PublicKeyToken='redacted' or one of its dependencies. The system cannot find the file
specified.

just installed the graph module and the graph.authentication module fine and still wont work even after a restart.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@shashishailaj
Copy link
Member

@shashishailaj Thank you for your feedback . We will investigate and update the thread further.

@shashishailaj
Copy link
Member

@RescueWhale I encountered similar error in my environment. I am testing a few more scenarios and we are trying to get information on this internally. We will update the thread once we have more information on this.

@shashishailaj
Copy link
Member

shashishailaj commented May 14, 2020

@RescueWhale I am getting a slightly different error but there is definitely some issue with the graph module in preview.

PS C:\Users\user\source\repos> Import-module Microsoft.Graph.Authentication
PS C:\Users\user\source\repos> Connect-Graph
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code AAAAAAAAA to authenticate.
Connect-Graph : Could not load file or assembly 'System.Security.Cryptography.ProtectedData, Version=4.0.5.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program
with an incorrect format.
At line:1 char:1
-+ Connect-Graph
-+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-Graph], BadImageFormatException
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.Graph.PowerShell.Authentication.Cmdlets.Connect
Graph

PS C:\Users\user\source\repos> Connect-Graph -Scopes "Directory.AccessAsUser.All"
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code AAAAAAAAA to authenticate.
Connect-Graph : Could not load file or assembly 'System.Security.Cryptography.ProtectedData, Version=4.0.5.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program
with an incorrect format.
At line:1 char:1
-+ Connect-Graph -Scopes "Directory.AccessAsUser.All"
-+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-Graph], BadImageFormatException
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.Graph.PowerShell.Authentication.Cmdlets.Connect
Graph

PS C:\Users\user\source\repos>

The above output was found by using Developer Powershell for VS 2019 environment . For some reason the Windows powershell ISE window gives a different error. It says that Connect-Graph : Device code terminal timed-out after 120 seconds. Please try again. But no browser window opens or no device code was provided on the command prompt.

image

So it does not work with Powershell ISE in windows 10. It may be by design but I cant confirm until I find more infromation.

We are trying to get this reviewed internally by the team and will update the page once we have more information.

@shashishailaj
Copy link
Member

shashishailaj commented May 14, 2020

@RescueWhale So after my testing I have come to conclusion that if you are using normal Windows Powershell x64 mode as shown in the picture below , the cmdlets provided in the article work without any issue.

image

PS C:\Users > Install-Module -Name Microsoft.Graph
PS C:\Users > Import-Module -Name Microsoft.Graph.Authentication
PS C:\Users > Connect-Graph -Scopes "User.Read.All"
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code HAAAAF5T7 to authenticate.
Welcome To Microsoft Graph!
PS C:\Users > Connect-Graph -Scopes "Directory.AccessAsUser.All"
Welcome To Microsoft Graph!
PS C:\Users > New-MgServicePrincipal -DisplayName "My Staff" -AppId ba9ff945-a723-4ab5-a977-bd8c9044fe61

DeletedDateTime      Id                                   AccountEnabled      AlternativeNames     AppDisplayName     AppId
-+ --------------      --                                   -------------- ---------------- -------------- -----
                daf47cd4-91f7-++++-a2bd-84986b169--- True           {}                              ba9ff945-a723-4a...


PS C:\Users > Get-MgServicePrincipal -ServicePrincipalId daf47cd4-91f7-++++-a2bd-84986b169--- |fl


AccountEnabled                      : True
AddIns                              : {}
AlternativeNames                    : {}
AppDisplayName                      : My Staff
AppId                               : ba9ff945-a723-4ab5-a977-bd8c9044fe61
AppOwnerOrganizationId              : f8cdef31-a31e-4b4a-93e4-5f571e91255a
AppRoleAssignedTo                   :
AppRoleAssignmentRequired           : False
AppRoleAssignments                  :
AppRoles                            : {}
ApplicationTemplateId               :
ClaimsMappingPolicies               :
CreatedObjects                      :
DeletedDateTime                     :
DisplayName                         : My Staff
Endpoints                           :
ErrorUrl                            :
HomeRealmDiscoveryPolicies          :
Homepage                            :
Id                                  : daf47cd4-91f7-470f-a2bd-84986b169dde
InfoLogoUrl                         :
InfoMarketingUrl                    :
InfoPrivacyStatementUrl             :
InfoSupportUrl                      :
InfoTermsOfServiceUrl               :
KeyCredentials                      : {}
LicenseDetails                      :
LoginUrl                            :
LogoutUrl                           : https://mystaff.microsoft.com/logout
MemberOf                            :
NotificationEmailAddresses          : {}
Oauth2PermissionGrants              :
OwnedObjects                        :
Owners                              :
PasswordCredentials                 : {}
PreferredSingleSignOnMode           :
PreferredTokenSigningKeyEndDateTime :
PreferredTokenSigningKeyThumbprint  :
PublishedPermissionScopes           : {}
PublisherName                       : Microsoft Services
ReplyUrls                           : {https://mystaff.microsoft.com}
SamlMetadataUrl                     :
SamlSingleSignOnSettingRelayState   :
ServicePrincipalNames               : {ba9ff945-a723-4ab5-a977-bd8c9044fe61}
ServicePrincipalType                : Application
SignInAudience                      : AzureADMultipleOrgs
SynchronizationId                   :
SynchronizationJobs                 :
SynchronizationSecrets              :
SynchronizationTemplates            :
Tags                                : {}
TokenEncryptionKeyId                :
TokenIssuancePolicies               :
TokenLifetimePolicies               :
TransitiveMemberOf                  :

I suggest you to try the above and let me know if that works for you . I believe , in your case the Microsoft.Graph.Authentication module may not be loading. Could you please try to start the PowerShell window with admin privileges and try the above . I believe it should work.

Thank you.

@shashishailaj
Copy link
Member

@RescueWhale This may give you error in Powershell ISE but it works in normal powershell (x64) window on Windows 10. We have this reported to the team internally and this is being looked into for powershell ISE . I would suggest you to check thi sagain on any windows 10 machine in your environment . It must work. We will close this issue now Should you have any further queries , please tag me to your reply and we will be happy to help .

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants