Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community

How to set the AIP label in the Powershell script to send the email?

Copper Contributor

I wrote a Powershell script to get the local administrators accounts from the endpoints and then distribute to the endpoints by using intune, then send the results back to IT by email.
However, the Microsoft Azure Information Protection (AIP) prompt out and request to select a label. May I know how to set the AIP label in the script, thus that the endpoint can send the email silently?
Or any method to bypass the AIP?

 

$result = ${env:TEMP}+"\"+${env:computername}+".csv"
Get-LocalGroupMember -Group "Administrators" | Format-Table –AutoSize | Export-Csv -Path $result

#create COM object named Outlook

$Outlook = New-Object -ComObject Outlook.Application

#create Outlook MailItem named Mail using CreateItem() method

$Mail = $Outlook.CreateItem(0)

#add properties as desired

$Mail.To = "xxxx@abc.com"
$Mail.Subject = ${env:computername}+" Local Administrators Account"
$Mail.Body = "IT Security Task"
$Mail.Attachments.Add($result);

#send message

$Mail.Send()

1 Reply

Hi @wilsonsyl,

 

I don't think there is a simple solution to your problem. I would suggest to find a way to bypass AIP. Maybe uploading the file to a share or something similar instead of sending it via mail.

 

BR,

Mattia