Forum Discussion
Variable in Graph Request Body (PowerShell)
- Jun 24, 2021SOLUTION: I had to add " | ConvertTo-Json" at the end Request Body
$PWCBody = @{
newPassword = $password
forceChangePasswordNextSignIn = $true
} | ConvertTo-Json
$PWCBody = @{
newPassword = $password
forceChangePasswordNextSignIn = $true
} | ConvertTo-Json
- Thiago-BeierSep 21, 2022Brass Contributor
I need to parse $var1 value into URI URL value for the graph api , that simply doesn't work
this works for me:
$var1 = $null
$results1 = $null
$url = 'https://graph.microsoft.com/v1.0/users/email address removed for privacy reasons?$select=displayName,officeLocation,city,usageLocation,department,onPremisesExtensionAttributes,userPrincipalName,onPremisesSamAccountName'
$url
$results1 = (Invoke-WebRequest -Headers $headerParams -Uri $url) | ConvertFrom-Json
$results1.onPremisesSamAccountName.ToUpper()
write-host "BULC code: " $results1.onPremisesExtensionAttributes.extensionAttribute3this doesn't
$va1 = $null
$results1 = $null
$var1 = "email address removed for privacy reasons"
$url = 'https://graph.microsoft.com/v1.0/users/$($a1)?$select=displayName,officeLocation,city,usageLocation,department,onPremisesExtensionAttributes,userPrincipalName,onPremisesSamAccountName' #usertofind
$url
$results1 = (Invoke-WebRequest -Headers $headerParams -Uri $url) | ConvertFrom-Json
$results1.onPremisesSamAccountName.ToUpper()
write-host "company code: " $results1.onPremisesExtensionAttributes.extensionAttribute3also this , doesn't work
$url = 'https://graph.microsoft.com/v1.0/users/$a1?$select=displayName,officeLocation,city,usageLocation,department,onPremisesExtensionAttributes,userPrincipalName,onPremisesSamAccountName' #usertofind
appreciate any help
Thiago