PowerShell Script for Accessing Sent Emails in Outlook and Exchange

Avinash 20 Reputation points
2025-02-02T05:13:01.9+00:00

I am developing a PowerShell script to retrieve sent email IDs from my Outlook sent mailbox for both the "To" and "CC" sections, from the beginning of the email account to the current date. I managed to create a script that works for a single user; however, it prompts for a notification acceptance when running in PowerShell.

The updated requirement is to extend this functionality to multiple users. The script should connect to the Exchange module with global admin credentials, access the Exchange Admin Center, and then loop through a list of users specified in the script. The goal is to access each user's sent mailbox to copy the sent email IDs and generate the output.

I am encountering errors while attempting to connect and access users in this manner. Assistance is needed in finding the correct command to connect to this environment.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,713 questions
Microsoft Exchange
Microsoft Exchange
Microsoft messaging and collaboration software.
659 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,613 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,009 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,075 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.