Alert NEW IP Address, Send email

Welcome Forums General PowerShell Q&A Alert NEW IP Address, Send email

Viewing 1 reply thread
  • Author
    Posts
    • #253055
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      Hey folks this is the first time I am using this forum and I am NEW to PowerShell.

      Here is the solution I am trying to develop. I would like to create a PowerShell script the will run using Windows scheduler and will run on Windows 10 pro for now. I may have to run the script on servers and other windows versions BUT for now the proof of concept is Windows 10 pro.

      The solution needs to check the External (public) IP address of the machine the script runs on. It will then write  the results from the IP check process into a text file. If the Text file is not present the script should also create a text file. for Example: MyIPAddress.txt

      Not only should the IP address be written to the file but also the date. For example the text file should look like this:

      123.873.22.200, 8/23/2020
      123.873.22.200, 8/24/2020

      ETC.. As you can see the IP address is written followed by a comma and then space and then date. This script will run once a day.

      The second part of the script now needs to compare the current IP check against the last entry IP address. IF they are different then send an email to the administrator.

      Because I haven’t used PowerShell I don’t have the scripts needed BUT I have found a few that could assist. For example here is a script for checking the IP address:

      The above script covers half of what I need it to do.

      I have another script I found online for sending emails using PowerShell BUT I have not got this to work. Below is the script along with the error message. Ideally, I would like this to be one script to do everything. It may also be nice to have a LOG file generated to capture any errors when the script runs.

      Email Script. Note I have removed SMTP Credentials for Gmail Account

      Error Message I get

      • This topic was modified 4 weeks ago by KBnetguy73. Reason: Spelling and DNS.com address display some additional characters at the end
      • This topic was modified 2 weeks, 5 days ago by kvprasoon. Reason: Code formatting
      • This topic was modified 2 weeks, 5 days ago by kvprasoon. Reason: code formatting
    • #254846
      Senior Moderator
      Topics: 9
      Replies: 1310
      Points: 4,789
      Helping Hand
      Rank: Community Hero

      looks like something related to your smtp server. Are you sure on smtp details, are they correct ?

      • This reply was modified 2 weeks, 5 days ago by kvprasoon. Reason: post correction
Viewing 1 reply thread
  • You must be logged in to reply to this topic.