How can i display my Powershell output in HTML

Viewed 29

I was writing a script witch filters some specific users, then i wanted to send those users to a notifications mail address. When i get the output from my script in the powershell it works fine, and sends me the list of the users in a system.array type format.

$domain= "company"
$directories = @(
    'OU=_Users,OU=Marketing,OU=Users,OU=Business,DC=sigren,DC=local'
    'OU=Users,OU=IT,OU=Users,OU=Business,DC=Company,DC=local'
)
$since = (Get-Date).AddHours(-24)
$users = @()
foreach ($directory in $directories)
{
$arr = Get-ADuser -filter * -properties WhenChanged -SearchBase $directory | Where { $_.WhenChanged -ge $since } | select -expand Name
$users + $arr
}

Later in the script where im creating the email with HTM, i use the variable from the powershell. It successfully sends an email to my address, but when i read the mail in my outlook, i only see string variable($company) in that mail.

<body>
<p>on $company the users $user got changed </p><br>
</body>

I couldn't find a way to convert my array or to display my variable in this mail, does someone know what i could try next?

0 Answers
Related