Forum Discussion
TonyRedmond
Nov 27, 2026MVP
Using PowerShell Here-Strings with Graph APIs
A reader was curious about the way of passing data to Graph API requests as shown in an article. It's because we used PowerShell here-strings to pass request bodies to Graph API requests. Normally, w...
mixrotechlo512
Nov 28, 2026Brass Contributor
Best solution: Use PowerShell Here-Strings to send JSON directly to Microsoft Graph API.
powershell
$Body = @"
{
"displayName": "IT Support Team",
"mailEnabled": true,
"mailNickname": "ITSupport",
"securityEnabled": false,
"groupTypes": ["Unified"]
}
"@
Invoke-MgGraphRequest -Method POST `
-Uri "https://graph.microsoft.com/v1.0/groups" `
-Body $Body `
-ContentType "application/json"
Why use Here-Strings?
- No need to create hash tables.
- Easy to copy and edit JSON.
- Preserves readable JSON formatting.
Tip: Use Here-Strings for quick Graph API requests and hash tables when working with dynamic PowerShell variables.