@Ashish Kumar Arya , I have done a test in my lab. Set the Primary user with a different user with Enrolled By.
Then import Intune module and connect to Microsoft Graph with the following command:
Import-Module Microsoft.Graph.Intune #import intune module
Update-MSGraphEnvironment -SchemaVersion beta #set schema version as beta
Connect-MSGraph #connect to MS grasp
After that, run the following command to get the testing device information:
Get-IntuneManagedDevice -managedDeviceId <Intune Device ID>
After checking the device information, I find the value of the "Enrolled by" is the same as userdisplayname. And the userid is the id of this user.
So for your question, I think we can refer to the "userid" property of the device.
Hope it can help.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.