I have done something similar. Please take a look at my example script shared in GitHub:
https://github.com/SimonSkotheimsvik/Community-By-SSkotheimsvik/blob/main/Microsoft/Intune/Win11-OEMInformation.ps1
I hope this can help you on your way for solving this problem.
Best regards,
Simon