Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Problem with send the result Empty by email

$
0
0

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


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>