Hi @Revathi Paramasivan ,
As a simple way, we could use the Microsoft 365 compliance center to search the unified audit log to view user and administrator activity in our organization.
If you want to use code, please refer to following articles:
https://github.com/AsishP/Office365AuditLogsAutomation
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
If an Answer 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.