Created
November 22, 2025 01:16
-
-
Save nathanmcnulty/39670f0adec2da5d0a6773c47cf14d3f to your computer and use it in GitHub Desktop.
Get MTP API token using Azure PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $tenantId = "YOUR-TENANTID" | |
| $fullToken = Get-AzAccessToken -ResourceUrl "https://securitycenter.microsoft.com/mtp" -TenantId $tenantId | |
| $secureToken = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($fullToken.Token) | |
| try { | |
| $token = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($secureToken) | |
| } finally { | |
| [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($secureToken) | |
| } | |
| $headers = @{ authorization= "Bearer $token" } | |
| Invoke-Restmethod -Uri "https://mde-dtc-snsexclusions-prd-eus3.securitycenter.windows.com/api/sense-collection/rules" -Headers $headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment