hello,
I allow myself to write to you I want to send the results of these two tests by email,
Here is my script is functional, but I get that result in the terminal, and email but it is empty.
What are the changes brought.
Thank you for your reply
$env:computername
"Name of machine it's $env "
# get le SID de la machine
$user = New-Object System.Security.Principal.NTAccount("$env:USERDOMAIN\$env:USERNAME")
$sid = $user.Translate([System.Security.Principal.SecurityIdentifier])
$sid.AccountDomainSid.ToString()
# send email
$body = "This is the message I want in the body of the email"
$user = "rafiachraf@hotmail.com"
$pass = ConvertTo-SecureString -String "mypassword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential $user, $pass
$mailParam = @{
To = "rafiachraf91@gmail.com"
From = "Me <rafiachraf@hotmail.com>"
Subject = "File report"
Body = $body
SmtpServer = "smtp.live.com"
Port = 587
Credential = $cred
}
Send-MailMessage @mailParam -UseSsl
achraf