microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
707 stars 168 forks source link

Trying to configure token lifetime policies for ServicePrincipal but getting FileNotFoundException #2268

Open blackadi opened 1 year ago

blackadi commented 1 year ago

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

Describe the bug

A clear and concise description of what the bug is. Trying to follow this doc to configure token lifetime policies but to service principal instead of application and being faced with the below error. image

To Reproduce Steps to reproduce the behavior:

  1. Execute New-MgServicePrincipalTokenLifetimePolicyByRef
  2. See error at New-MgServicePrincipalTokenLifetimePolicyByRef : Could not load file or assembly 'Microsoft.Graph.Authentication, Version=1.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

Expected behavior

Via direct Graph API call I'm able to achieve the above but via Graph SDK this is not working.

Debug Output

Run the problematic command with -Debug and paste the resulting debug stream below. ⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs. New-MgServicePrincipalTokenLifetimePolicyByRef : Could not load file or assembly 'Microsoft.Graph.Authentication, Version=1.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1

  • New-MgServicePrincipalTokenLifetimePolicyByRef -ServicePrincipalId $s ...
  • CategoryInfo : NotSpecified: (:) [New-MgServicePr...icyByRef_Create], FileNotFoundException
  • FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.NewMgServicePrincipalTokenLifetimePolicyByRef_Create

Module Version

Please run Get-Module Microsoft.Graph* after cmdlet execution and paste the output below. If a module cannot be installed or imported, please run Get-Module -ListAvailable and paste the output. ModuleType Version Name ExportedCommands


Script 1.9.1 Microsoft.Graph.Applications {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgSe... Script 2.1.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G... Script 2.1.0 Microsoft.Graph.Identity.SignIns {Confirm-MgRiskyServicePrincipalCompromised, Confirm-MgRis

Environment Data

Please run $PSVersionTable and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine. Name Value


PSVersion 5.1.22621.1778 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.1778 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Screenshots

If applicable, add screenshots to help explain your problem. image

Additional context

Add any other context about the problem here.

timayabi2020 commented 1 year ago

@blackadi this looks like a versioning conflict between the Microsoft.Graph.Authentication module and Microsoft.Graph.Identity.SignIns module. Please try and install the latest Microsoft Graph module by running this command Install-Module -Name Microsoft.Graph -Repository PsGallery -AllowClobber -Force. For further installation instructions and usage, please refer to the reference documentation here.

blackadi commented 1 year ago

@timayabi2020 I've tried to update the modules to the latest version as per your recommendation but still getting the same error image

blackadi commented 1 year ago

@timayabi2020 any feedback from your side