msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Invoke-MgGraphRequest not working for "api.securitycenter.microsoft.com"
Describe the bug
I was trying to use Invoke-MgGraphRequest with api.securitycenter and it doesn't work. It works using old MSAL.PS methods so I would guess it's the same thing. Is that expected?
Connect-MgGraph -Scopes 'User.Read.All', 'Directory.Read.All', 'SecurityIdentitiesHealth.Read.All', 'SecurityAlert.Read.All' -NoWelcome
# works
Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/users" -Method Get -Verbose
# doesn't work
Invoke-MgGraphRequest -Uri "https://api.securitycenter.microsoft.com/api/alerts" -Method Get -Verbose
Expected behavior
Invoke-MgGraphRequest should work with all URL's
How to reproduce
Connect-MgGraph -Scopes 'User.Read.All', 'Directory.Read.All', 'SecurityIdentitiesHealth.Read.All', 'SecurityAlert.Read.All' -NoWelcome
# works
Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/users" -Method Get -Verbose
# doesn't work
Invoke-MgGraphRequest -Uri "https://api.securitycenter.microsoft.com/api/alerts" -Method Get -Verbose
SDK Version
2.23.0
Latest version known to work for scenario above?
No response
Known Workarounds
MSAL.PS module
Debug output
Click to expand log
```Configuration
- Windows 11 PS 7
Other information
Not relevant
It seems there are also graph.microsoft.com security endpoints as available:
- https://developer.microsoft.com/en-us/graph/graph-explorer?request=security/alerts_v2&method=GET&version=beta&GraphUrl=https://graph.microsoft.com
And this works:
$T = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/security/alerts_v2" -Method Get -Verbose
$T.Value
So I would guess the question is - if that's the right approach and api.securitycenter.microsoft.com is deprecated?
Hi @PrzemyslawKlys apologies for the delayed response. Yes, that particular endpoint was deprecated in favour of Microsoft Defender XDR alerts API. You can find the documentation here.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Closing this issue due to inactivity.