-
Notifications
You must be signed in to change notification settings - Fork 0
Send AuditEmail
external help file: ADAuditTasks-help.xml Module Name: ADAuditTasks online version: https://github.com/CriticalSolutionsNetwork/ADAuditTasks/wiki/Send-AuditEmail schema: 2.0.0
This is a wrapper function for Send-MailKitMessage and takes string arrays as input.
Send-AuditEmail -AttachmentFiles <String[]> [-SMTPServer <String>] [-Port <Int32>] [-UserName <String>] [-SSL]
[-From <String>] [-To <String>] [-Subject <String>] [-Body <String>] [-Pass <SecureString>]
[<CommonParameters>]
Send-AuditEmail -AttachmentFiles <String[]> [-SMTPServer <String>] [-Port <Int32>] [-UserName <String>] [-SSL]
[-From <String>] [-To <String>] [-Subject <String>] [-Body <String>] -Function <String> -FunctionApp <String>
-Token <String> -CertificateThumbprint <String> [<CommonParameters>]
Other Audit tasks can be used as the -AttachmentFiles parameter when used with the report switch.
Send-AuditEmail -SMTPServer "smtp.office365.com" -Port 587 -UserName "[email protected]" `
-From "[email protected]" -To "[email protected]" -Pass (Read-Host -AsSecureString) -AttachmentFiles "$(Get-ADActiveUserAudit -Report)" -SSL
This will automatically send the report zip via email to the parameters specified. There is no cleanup of files. Please cleanup the directory of zip's if neccessary.
Send-AuditEmail -SMTPServer "smtp.office365.com" -Port 587 -UserName "[email protected]" `
-From "[email protected]" -To "[email protected]" -AttachmentFiles "$(Get-ADActiveUserAudit -Report)" -FunctionApp "MyVaultFunctionApp" `
-Function "MyClientSpecificFunction" -Token "ABCDEF123456" -SSL
This will automatically send the report zip via email to the parameters specified. There is no cleanup of files. Please cleanup the directory of zip's if neccessary.
The full filepath to the zip you are sending: -AttachmentFiles "C:\temp\ADHostAudit\2023-01-04_03.45.14_Get-ADHostAudit_AD.CONTOSO.COM.Servers.zip"
The Audit reports output this filename if the "-Report" switch is used allowing it to be nested in this parameter for ease of automation.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
The body of the message, pre-populates with the same data as the subject line. Specify body text in the function parameters to override.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: "$($script:MyInvocation.MyCommand.Name -replace '\..*') report ran for $($env:USERDOMAIN) on host $($env:COMPUTERNAME)."
Accept pipeline input: False
Accept wildcard characters: False
API key for the Azure Function App
Type: String
Parameter Sets: Func
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is who the email will appear to originate from. This is either the same as the UserName, or, if delegated, access to an email account the Username account has delegated permissions to send for. Link: https://learn.microsoft.com/en-us/microsoft-365/admin/add-users/give-mailbox-permissions-to-another-user?view=o365-worldwide
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If you are using the optional function feature and created a password retrieval function, this is the name of the function in Azure AD that accesses the vault.
Type: String
Parameter Sets: Func
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If you are using the optional function feature, this is the name of the function app in Azure AD.
Type: String
Parameter Sets: Func
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Takes a SecureString as input. The password must be added to the command by using: -Pass (Read-Host -AsSecureString) You will be promted to enter the password for the UserName parameter.
Type: SecureString
Parameter Sets: Pass
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The following ports can be used to send email: "993", "995", "587", "25"
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
The SMTP Server address. For example: "smtp.office365.com"
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Switch to ensure SSL is used during transport.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The subject is automatically populated with the name of the function that ran the script, as well as the domain and hostname.
If you specify subject in the parameters, it will override the default with your subject.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: "$($script:MyInvocation.MyCommand.Name -replace '\..*') report ran for $($env:USERDOMAIN) on host $($env:COMPUTERNAME)."
Accept pipeline input: False
Accept wildcard characters: False
This is the mailbox who will be the recipient of the communication.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If you are using the optional function feature, this is the api token for the specific function. Ensure you are using the "Function Key" and NOT the "Host Key" to ensure access is only to the specific funtion.
Type: String
Parameter Sets: Func
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The Account authorized to send email via SMTP. From parameter is usually the same.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://github.com/CriticalSolutionsNetwork/ADAuditTasks/wiki/Send-AuditEmail
https://criticalsolutionsnetwork.github.io/ADAuditTasks/#Send-AuditEmail