I want to retrieve the owners of a deleted app registration without first restoring it, so I run the following PowerShell cmdlet:
(Get-MgDirectoryDeletedItemAsApplication -DirectoryObjectId 46617322-518d-4b76-9b69-f17d6b035ae4 -ExpandProperty Owners).Owners
While several properties are defined on the application object, I can't expand the owners property to retrieve the list of owners.
How to retrieve the owners of a deleted app registration without restoring it first?
I want to retrieve the owners of a deleted app registration without first restoring it, so I run the following PowerShell cmdlet:
(Get-MgDirectoryDeletedItemAsApplication -DirectoryObjectId 46617322-518d-4b76-9b69-f17d6b035ae4 -ExpandProperty Owners).Owners
While several properties are defined on the application object, I can't expand the owners property to retrieve the list of owners.
How to retrieve the owners of a deleted app registration without restoring it first?
Share Improve this question asked Feb 5 at 9:27 ShuzhengShuzheng 13.9k28 gold badges114 silver badges225 bronze badges 3 |1 Answer
Reset to default 1No way to directly get owners of a soft-deleted application, but you can do just the opposite and retrieve a list of deleted applications owned by the specified user.
There is no PowerShell cmdlet for this, but you can use the Invoke-MgGraphRequest
cmdlet.
$params = @{
userId = 'user_guid'
type = 'Application'
}
Invoke-MgGraphRequest -Uri 'https://graph.microsoft.com/v1.0/directory/deletedItems/getUserOwnedObjects' POST -Body $params
Iterate over all users and get a list of owned soft-deleted applications. Check if the specific application is included in the list for each user.
Get-MgApplicationOwner -ApplicationId $deletedApp.Id
– Rukmini Commented Feb 5 at 9:33Get-MgApplicationOwner_List: Resource 'xxxxxxxx-518d-4b76-9b69-f17d6b035ae4' does not exist or one of its queried reference-property objects are not present.
– Shuzheng Commented Feb 5 at 9:46