@fatimazahrahida-9743
Reviewed the script which was sent yesterday and I see you are trying to authenticate Azure AD using Invoke-RestMethod with Client Credential flow ( below snipped from script for reference )
I came across this article with the similar requirement - https://stackoverflow.com/questions/71265186/how-do-i-authenticate-to-aad-using-invoke-restmethod-with-clientcredential-flow
You need to make few changes to your script to authenticate via Certificate, refer to the below article ( section: Acquire an Access token using a certificate ).
https://adamtheautomator.com/powershell-graph-api/#:~:text=RestMethod%20%40PostSplat-,Acquire%20an%20Access%20Token%20(Using%20a%20Certificate),-The%20authenticate%20to
Let me know if you have any questions.
Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.