document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Code Snippet from aperturescience.su
  2.  
  3. $ipfile = "%temp%\\externalip.txt"
  4. $iponfile = (Get-Content $ipfile -ErrorAction SilentlyContinue)
  5.  
  6. try
  7. {
  8.     $externalip = Get-ExternalIP
  9.  
  10.     if ($externalip -eq $iponfile)
  11.     {
  12.         #
  13.         # IP Addresses match, all is good
  14.         #
  15.        
  16.         # We might want to do something here, if you were using my standard template, a line like:
  17.         #   send-email "IP Address has not changed" $true
  18.         # would be a neat thing to add
  19.     }
  20.     else
  21.     {
  22.         #
  23.         #IP Address do not match, something very bad may have happened! Do Something!
  24.         #
  25.        
  26.         # We need to save the new ip address to the log file before we do anything else.
  27.         $externalip | Out-File $ipfile
  28.        
  29.         # you could continue and do almost anything, if you were using my standard template, a line like:
  30.         #   send-email "IP Address has changed" $false
  31.         # would be a neat thing to add
  32.     }
  33. }
  34. catch
  35. {
  36.     #
  37.     # Error occured getting the external ip address
  38.     #
  39.     # We might want to do something here, if you were using my standard template, a line like:
  40.     #   send-email "Error getting ip address" $false
  41.     # would be a neat thing to add
  42. }
  43.  
  44. # Code Snippet from aperturescience.su
');