Aug 27 2021 07:06 AM - edited Aug 27 2021 07:09 AM
I'm working on restoring deleted Groups (Teams) and I'm using Powershell and MS Graph for all the necessary step to complete the process and all steps is working but one. I have a step that's causing me some trouble, changing the Display Name and add content to Description for each of restored groups.
I tried different formats in creating the payload for the body; however, all have failed. Can someone take a look at what I have and show me what I'm missing so that I can create the correct format for the payload so that I can change a group's display name and description using Graph API.
$ArchiveDisplayName = $GrpsInfoRequest.displayName
$ArchiveDate = Get-date -Format "MM/dd/yyyy:HH:mm"
[string]$ArchiveDiscription = "Group Restored and Archived on $ArchiveDate"
[string]$RestoreArchiveDisplayName = "DO NOT DELETE RESTORED TEAM - " + $ArchiveDisplayName
$Body = @{description = $ArchiveDiscription
displayName = $RestoreArchiveDisplayName
} | ConvertTo-Json
$UpdateGrpNameRequestURI = "https://graph.microsoft.com/v1.0/groups/$ArchiveTeamID"
$UpdateTeamRequest = Invoke-RestMethod -Headers $HeaderRW -Uri $UpdateGrpNameRequestURI -Method PATCH -Body $Body -ContentType "application/json"
######################### ERROR I'M GETTING ###########################
VERBOSE: PATCH https://graph.microsoft.com/v1.0/groups/XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXX with -1-byte payload
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:9 char:37
+ ... = Invoke-RestMethod -Headers $HeaderRW -Uri $UpdateGrpNameR ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
################################# END ################################
Thank You,
-Larry