We are looking to use the API to create, modify and delete admin accounts from our AD in security groups. I have a test user I created the account for just fine, and I find and delete said user pretty easily with a little POSH work. However, when I run the update command, it processes "successfully" but the user isn't updated.
We use the "orgAccess" field to denote read/write privileges since our setup is simple. We have a few users who are "read-only" and some network guys that are "full." I'd also like to be able to update the name and/or email address based on HR required name changes.
My script is below. Any advice would be great. Thank you.
-----------------
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add("Accept", "*/*")
$Headers.Add("X-Cisco-Meraki-API-Key", "$Key")
<# GET LIST OF USERS AND NARROW TO REQUESTED #>
$Response = Invoke-RestMethod 'https://$($Key).meraki.com/api/v0/organizations/$($Org)/admins' -Method 'GET' -Headers $Headers
$NDX = $Response.email.IndexOf("%Email%")
$User = $Response[$NDX]
<# SET NEW VARIABLES #>
$URL = 'https://$($Base).meraki.com/api/v0/organizations/$($Org)/admins/'+$user.id
$Body2 = '{
`n "name": "$($DisplayName)",
`n "email": "$($Email)",
`n "networks": [],
`n "tags": [],
`n "orgAccess": "$($AccessType)"
}'
<# UPDATE ACCOUNT #>
$Response2 = Invoke-RestMethod $URL -Method 'PUT' -Headers $Headers -Body $Body2
$Response2