|
Scripting noob here working on my first powershell script and I'm wondering if anyone would be able to help me out. What I'm trying to do is periodically check the external IP address of a machine and determine if it has changed or not. Preferably if the IP has changed it would create an event log that will be picked up by another monitoring tool. Feel free to tell me I'm retarded for what I've got so far. It's not complete and doesn't quite do what I want yet, but I think I'm on the right track. I need to do some serious reading up on powershell in general but I've picked up a little bit working on this script so far. code:
|
# ¿ Nov 10, 2011 08:19 |
|
|
# ¿ Apr 30, 2024 16:52 |
|
It was a rough draft. My goal with $oldip was to pull the IP from the last event log and compare it to the recently polled IP from whatismyip. I'd like to use a loop to send out a different type of event log if the IP changes and perhaps send out an email. The path for the iplog.txt was correct. That was the original log that I wrote to; using events was something I tacked quickly at the end but I think would be a superior method. I may still keep that log file just to have a consolidated list of past IP's. Would there be a way to only append the log when a new IP is discovered instead of everytime the script is run? Appreciate the help. Edit: That's awesome! I will have to break down the details and figure out why you did what you did tomorrow but that looks like exactly what I need to get this to work. joe944 fucked around with this message at 11:15 on Nov 10, 2011 |
# ¿ Nov 10, 2011 11:07 |
|
You're awesome, I got everything working perfectly. Now to do some experimentation for more advanced features! I think powershell is going to come in very handy..
|
# ¿ Nov 11, 2011 01:04 |
|
MEAT TREAT posted:I did something stupid. I associated .ps files with notepad++ because I was tired of having them open in regular notepad, but I've lost the ability to right-click and run with powershell. What OS are you running? Does right click > open with > choose default program and select powershell work?
|
# ¿ Nov 13, 2011 02:01 |