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

Occasional Visitor

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 = ""
$Mail.Subject = ${env:computername}+" Local Administrators Account"
$Mail.Body = "IT Security Task"

#send message


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.