Closed fujiant closed 7 months ago
If this is an issue with some inter-module dependency the script could be split out into 2 as the use of each module is independant
All the Set-APIPermissions
lines and function could be one script with only the MsGraph module needed.
All the Set-RBACPermissions
lines and function could be another with only the Az module needed.
@piaudonn thoughts? Looks like this may be more of a module issue than a issue with the script.
Thank you for fast response! Meanwhile I've tried removing all of Az and Microsoft.Graph and reinstalling the modules. It has not made a difference. My colleagues could also reproduce the issue on their Windows workstations with latest module versions and Windows Powershell 5.1.
I also tested on Ubuntu Linux with Powershell 7 and could not reproduce the issue, the script seemed to work there. So I did test with Powershell 7 and latest modules on my Windows 10 workstation, but the issue still remains. The first error message however is a bit different.
[+] Connect to the Azure AD tenant: <REDACTED>
Connect-MgGraph: C:\Users\<REDACTED>\Downloads\<REDACTED>.ps1:49
Line |
49 | Connect-MgGraph -TenantId $TenantId -Scopes AppRoleAssignment.ReadWri …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not load file or assembly 'Microsoft.Identity.Client.Extensions.Msal, Version=2.25.3.0, Culture=neutral,
| PublicKeyToken=<REDACTED>'. Could not find or load a specific file. (0x80131621)
[+] Connecting to to the Azure subscription: <REDACTED>
[+] Setting permission Data.Read on Get-UEBAInsights
Get-MgServicePrincipal_List: C:\Users\<REDACTED>\Downloads\<REDACTED>.ps1:92
@briandelmsft indeed, that's a PowerShell/Module issues, that you would get regardless of what is using those cmdlets.
The first error looks a lot like what is described here: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2284 and fixed by updating the Az module.
I can't repro on my side. I'll try later on a lab to see if I can repro. In the meantime, I would encourage you to keep those GitHub issues in the microsoftgraph org going. I know that's not great of an answer, but that's where the SMEs for those problems are.
Yes, as mentioned, module updates do not seem to have an effect on this. I have the latest. I have also tried to remove everything and old versions and then reinstall from scratch. Still getting the errors when Az and Graph are both used in the same file.
@fujiant I had the same exact issue, but downgrading Microsoft.Graph.Applications/Authentication & Az.Accounts/Resources did the trick for me. I used:
Yes, as mentioned, module updates do not seem to have an effect on this. I have the latest. I have also tried to remove everything and old versions and then reinstall from scratch. Still getting the errors when Az and Graph are both used in the same file.
But I am not sure if there is anything, we as STAT owner can do about it, it seems that the root cause of the problem is outside of the solution. @fujiant I don't want to look like I am trying to punt here, but I am unsure of how we can help here. Perhaps we can provide a "manual" way to grant the permissions in the documentation. Would that help?
Yes, as mentioned, module updates do not seem to have an effect on this. I have the latest. I have also tried to remove everything and old versions and then reinstall from scratch. Still getting the errors when Az and Graph are both used in the same file.
But I am not sure if there is anything, we as STAT owner can do about it, it seems that the root cause of the problem is outside of the solution. @fujiant I don't want to look like I am trying to punt here, but I am unsure of how we can help here. Perhaps we can provide a "manual" way to grant the permissions in the documentation. Would that help?
Thanks, this would be helpful! I am keeping the issue up in the Graph side, still no solution on their end.
The issue seems to be related to one's system configuration and not the script per say. I will archive this issue. It will remain searchable, but it will not show as open anymore.
Describe the bug Running GrantPermissions.ps1 yields an error. I have tried updating all of Az module and all of Graph and .NET frameworks on my workstation and nothing seems to resolve this. Could be related to this https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2148
The precise errors I am getting are:
I have used Update-Module to update Az and Graph to latest. Here's what my Get-InstalledModule outputs:
Module Name Deploy
To Reproduce Steps to reproduce the behavior:
.\GrantPermissions.ps1
Expected behavior No errors, script runs as supposed to
Additional context I am running Windows Powershell 5.1 that comes with Windows 10.