I've been trying to restore a deleted Office 365 user account, but I've learned the hard way that I can no longer connect to the MSOL service as it seems to have been replaced by Microsoft Graph. I'm looking for guidance on how to accomplish this with the new Microsoft Graph commands. The commands I used before were for MSOL, like `Restore-MsolUser` and `Get-MsolUser`, but I'm unsure what the equivalent commands are now. Can someone help me find the new commands for these tasks?
4 Answers
I totally get where you’re coming from! The Microsoft Graph modules can feel pretty overwhelming. In my opinion, using direct API calls might actually simplify things a bit, despite making the scripts larger. It’s less prone to breaking changes.
You’ll want to check out the new commands for Microsoft Graph; they’ve completely replaced the old MSOL commands. There's a great resource here that maps the old MSOL cmdlets to the new ones: https://learn.microsoft.com/en-us/powershell/microsoftgraph/azuread-msoline-cmdlet-map?view=graph-powershell-1.0&pivots=msonline
I can’t connect either; I got the same access denied message this morning when I tried using `Connect-MsolService`. It looks like MSOL compatibility is definitely gone.
I’m struggling with getting the `Get-MgUser` command to work. It throws an error, saying multiple errors occurred— is anyone else facing this?
It sounds like you might have some conflicting MS Graph modules. There’s a guide on fixing the `Get-MgUser` errors here: https://bonguides.com/how-to-fix-get-mguser-one-or-more-errors-occurred.
You can find detailed guides on how to restore users and permanently delete them using Microsoft Graph PowerShell. Here are two handy links: 1. [Restoring Deleted Users](https://o365info.com/restore-microsoft-entra-id-users/) and 2. [Permanently Delete Users](https://www.alitajran.com/permanently-delete-users-microsoft-365/). These should help clarify things!

Just so you know, I ran into similar issues trying to connect to MSOL. I found a post discussing access errors that may be useful: https://learn.microsoft.com/en-us/answers/questions/2275816/connect-msolservice-access-denied.