Forum Discussion
Adamneedshelpwithpowershell
Sep 08, 2025Copper Contributor
Problem restoring deleted user with mggraph
Hello, I have done a few 365 migration and almost everytime there are some user data that has been missed in the migration. Earlier I solved this by restoring the 365 user in the source tenant t...
LainRobertson
Sep 09, 2025Silver Contributor
Hi Adamneedshelpwithpowershell,
Use the Restore-MgDirectoryDeletedItem commandlet (from the Microsoft.Graph.Identity.DirectoryManagement module) in conjunction with the autoReconcileProxyConflict header:
- Restore-MgDirectoryDeletedItem (Microsoft.Graph.Identity.DirectoryManagement) | Microsoft Learn
- Restore deleted directory object item - Microsoft Graph v1.0 | Microsoft Learn
Cheers,
Lain
Adamneedshelpwithpowershell
Sep 09, 2025Copper Contributor
Hi,
Thanks for the response, I looked at this yesterday and tried it aswell.
I think this should work, but it complains about the BodyParameter:
Restore-MgDirectoryDeletedItem : A parameter cannot be found that matches parameter name 'BodyParameter'.
So most likely I am using this wrong in some way, I tried doing these two ways:
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
autoReconcileProxyConflict = $true
}
Restore-MgDirectoryDeletedItem -DirectoryObjectId e0995e5e-13d8-40eb-a29e-9d********733 -BodyParameter $params
Ex2:
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
newUserPrincipalName = "E********.E*******@newdomain.onmicrosoft.com"
}
Restore-MgDirectoryDeletedItem -DirectoryObjectId e0995e5e-13d8-40eb-a29e-9***********3 -BodyParameter $params
Still get the same error with body parameter.
/Adam