The below contents are from the $Results variable I got from my larger script.
Code: Select all
MachineName : PRDDC03.domain.com
Id : 4624
TimeCreated : 4/09/2020 12:12:12 PM
Account : DOMAIN\SVC-SQL
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 172.16.32.99
SourceName :
MachineName : PRDDC02-VM.domain.com
Id : 4624
TimeCreated : 3/09/2020 10:21:27 AM
Account : DOMAIN\SVC-prtg
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 10.10.13.97
SourceName :
MachineName : AD01.domain.com
Id : 4624
TimeCreated : 3/09/2020 9:15:27 AM
Account : DOMAIN\Admin.local
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 192.168.32.58
SourceName :
MachineName : SVRDC33.domain.com
Id : 4624
TimeCreated : 28/08/2020 4:51:13 PM
Account : DOMAIN\GLobal.Admin
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 192.168.13.66
SourceName :
MachineName : AD01.domain.com
Id : 4624
TimeCreated : 28/08/2020 11:54:27 AM
Account : DOMAIN\svc.avs
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 192.168.1.66
SourceName :
MachineName : AD02.domain.com
Id : 4624
TimeCreated : 26/08/2020 9:29:53 AM
Account : DOMAIN\testing1
LogonType : 3
LogonTypeString : Network
WorkstationName :
SourceIP : 192.168.13.77
SourceName :
Code: Select all
192.168.1.66 - LAPTOP66
192.168.32.58 - No-DNS
10.10.13.97 - SVRPRTG01
172.16.32.99 - NoDNS
Hence I need your help.Write-Host "Unique IP addresses are as follows"**
Write-Host "$(($Results | Select-Object -ExpandProperty SourceIP -Unique)) - Resolve-DnsName -Type A -Name (($Results | Select-Object -ExpandProperty SourceIP -Unique))"
I want to convert the $Results variable as HTML so I can attach it in Send-MailMessage body
Code: Select all
$params = @{
SmtpServer = 'SMTP.DOMAIN.com'
From = "$env:COMPUTERNAME@$env:userdnsdomain"
To = 'boss@IT.com'
Subject = "The report email as at $(Get-Date -Format 'F')"
Body = $Results
BodyAsHtml = $true
}
Thank you in advance.