Skip to content

Instantly share code, notes, and snippets.

@cmaggiulli
Created June 17, 2018 22:24
Show Gist options
  • Save cmaggiulli/12c8e6ed72d2f884e9aa3f63aa2188f4 to your computer and use it in GitHub Desktop.
Save cmaggiulli/12c8e6ed72d2f884e9aa3f63aa2188f4 to your computer and use it in GitHub Desktop.
A PowerShell script I use to retrieve the IP address of a user (see: family member) I'm attempting to assist with a remote viewing tool.
$ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}
$EmailTo = "postmaster@yourdomain.com"
$EmailFrom = "DoNotReply@example.comm"
$Subject = "$($ip.ipaddress[0])"
$Body = "$($ip.ipaddress[0])"
$SMTPServer = "smtp.example.com"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($EmailFrom, "P@33w0rD!");
$SMTPClient.Send($SMTPMessage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment