Hello @mark terry ,
Thank you for your reaching out to Microsoft QnA Platform. I guess you should be able to replace "Get-MsolUser -ReturnDeletedUsers" with "Get-MgDirectoryDeletedItem -Filter "userPrincipalName eq '$($User.userprincipalname)'".
- Get-MgDirectoryDeletedItem - Retrieves the properties of a recently deleted application, group, servicePrincipal, administrative unit, or user object from deleted items.
- More information on this command can be found on following article: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.identity.directorymanagement/get-mgdirectorydeleteditem?view=graph-powershell-1.0
Hope this will help. Please "Accept the answer" if the information helped you. This will help us and others in the community as well.