Get a distribution list from an email CC inside outlook

To extract all the emails Id from the distribution list you can try using shell script.

Step1- open Notepad and paste the following code and save it as .ps1 file

Note- You will get popup in run time where you have to enter your outlook Id and password

$o365cred = Get-Credential emailid@domain.com // enter your own outlook email id
$session365 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://ps.outlook.com/powershell/” -Credential $o365cred -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession $session365 -AllowClobber) -Global
$DGName = “Distribution list email Id”
Get-DistributionGroupMember -Identity $DGName | Select PrimarySMTPAddress |
Export-CSV “D:\DlList.csv- File where email id are extracted” -NoTypeInformation -Encoding UTF8

Step 2- If you directly run the shell script or invoke the shell script - You may encounter error stating- "cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies "

to avoid the following error you can create a bat file to execute the shell script-
Steps for the same are as below-
Open a notepad and paste the below code and save it as .bat file

@echo off
color 1F
echo.

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "path of the shell script "
:EOF
echo Waiting seconds
timeout /t 40 /nobreak > NUL

Step 3 In the UiPath , you can use start process to start activity to launch the bat file
image

Thanks & Regards,
Lipika Porey