The Restore-MsolUser cmdlet in PowerShell restores a deleted user in Microsoft Office 365. The command restores a user that is in the deleted user’s view to its original state. The deleted users view contains the deleted users for 30 days.
The syntax to restore a user in Azure Active Directory is given below.
Restore-MsolUser
-ObjectId <Guid>
-UserPrincipalName <String>
[-AutoReconcileProxyConflicts]
[-NewUserPrincipalName <String>]
[-TenantId <Guid>]
[<CommonParameters>]
In this article, we will discuss how to use the Restore-MsolUser cmdlet in PowerShell to restore a user that is in the deleted user’s view.
How to Restore a User
To restore a user in Office 365 with PowerShell, use the Restore-MsolUser cmdlet with the -UserPrincipalName
parameter. The -UserPrincipalName
parameter specifies the user ID of the user to restore.
Restore-MsolUser -UserPrincipalName "[email protected]"
This command restores the user “[email protected]” from the Deleted user container to the Active user container.
How to Restore a User and Remove Conflicts
To restore a user and remove the conflicts in Office 365, use the Restore-MsolUser cmdlet with the -AutoReconcileProxyConflicts
parameter.
The -AutoReconcileProxyConflicts
parameter indicates the any proxy addresses that cause conflicts are removed for the user.
Restore-MsolUser -UserPrincipalName "[email protected]" -AutoReconcileProxyConflicts
This command restores the user “[email protected]” from the Deleted user container to the Active users container, removing any conflicting proxy addresses.
How to Restore a User with a New User Pricipal Name
To restore a user from the Deleted users container and assign a new user principal name, use the Restore-MsolUser cmdlet with the -NewUserPrincipalName
parameter.
The -NewUserPrincipalName
specifies a new user principal name to use when restoring a user.
Restore-MsolUser -UserPrincipalName "[email protected]" -NewUserPrincipalName "[email protected]"
This command restores the user “[email protected]” from the Deleted users container to the Active user container with new user principal name “[email protected]”.
Conclusion
I hope the above article on how to use the Restore-MsolUser cmdlet in PowerShell to restore a user in Office 365 is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.