0 votes

Hello,

is there a way to save powershell variable to axases attribute and send it via "send email notification" in Scheduled task?

for example, check if Office 2016 is installed and send report via email.

` $software = "Microsoft Office Professional Plus 2016" $installed = Get-WmiObject -ComputerName %cn% -Class Win32Product | sort-object Name | Select-Object Name | Where-Object {$.Name -eq $software}

if (-not $installed) {$customattrib = " %cn% - $($installed.name) not installed"} else {$customattrib = " %cn% - $($installed.name) installed"} ` then add $customattrib value to Send email notification.

Thank you

by (20 points)

1 Answer

0 votes
by (213k points)

Hello,

Do we understand correctly that the script you referenced and the Send email notification action will be executed in the same Scheduled Task? If that is correct, there is no possibility to pass the $customattrib variable value to the action. You will need to send the notification right in the script itself. Finally, it will look like the following:

$software = "Microsoft Office Professional Plus 2016"
$installed = Get-WmiObject -ComputerName %cn% -Class Win32Product | sort-object Name | Select-Object Name | Where-Object {$.Name -eq $software}

if (-not $installed) 
{
    $customattrib = " %cn% - $($installed.name) not installed"
} 
else 
{
    $customattrib = " %cn% - $($installed.name) installed"
}

# Send mail
$Context.SendMail("recipient@company.com", "Office 2016", $customattrib, $Null)
0

Nice, thank you!

Is there a way to use HTML formatting in $context.sendemail body?

$subject = test
$body =
@"
<h1>some
random
text with HTML formatting</h1>
"@

$context.SendMail("mail@mail.com",$Subject, $body, $null)

0

Hello,

Yes, you will just need to specify the variable containing the HTML formatted text in the fourth parameter of the $Context.SendMail method and set the third parameter to $Null. Finally, the script will look like the following:

$subject = test
$body =
@"
<h1>some
random
text with HTML formatting</h1>
"@

$context.SendMail("mail@mail.com",$Subject, $null, $body)

Related questions

0 votes
1 answer

Hi, is it possible to save to an Adaxes attribute the value of the last Sign In from Azure AD? When we query users for Last Logon, we, of course, can only see the Last Logon value from AD It would be very useful to know the latest login in Azure AD as well

asked Jun 22, 2020 by manuel.galli (100 points)
0 votes
1 answer

I have a scheduled task that runs a Powershell script against an AD group, "Group 1". I need to get all of the members of Group 1, and add them to Group 2. The ... identity in the error message start with 'user;'? What is the correct way to accomplish this?

asked Aug 27, 2019 by ngb (70 points)
0 votes
1 answer

I have to generate an Excel sheet populated with some users informations. It works on the server itself, but not when i run it via Custom commands. There is the code that ... it does'nt open and throws an error : How to interact with com objects on Adaxes?

asked Nov 29, 2021 by diaz801 (20 points)
0 votes
1 answer

I am trying to connect to teams via powershell in adaxes to run the following commands. Set-CsUser -Identity &lt;UPN&gt; -EnterpriseVoiceEnabled $true -HostedVoiceMail $true ... (policyname)" I am not able to run the following though, Connect-MicrosoftTeams

asked Apr 22, 2021 by TJ_Umredkar (130 points)
0 votes
1 answer

Hi All, We are looking at using Adaxes however would like to be able to see the Adaxes logs within McAfee SIEM. Has anyone tried and tested this and could give any ... monitoring. Does Adaxes have a preferred route to get logs to the SIEM? Many Thanks!

asked Apr 8, 2020 by antondubek (440 points)
2,640 questions
2,375 answers
6,305 comments
985,969 users