Quantcast
Viewing all articles
Browse latest Browse all 8820

Please help - set-receiveconnector IP list from txt, to run every 10 minutes

I've created a batch file to run a Kix script to import a list of IP addresses that update every 10 minutes (allowing users of a group to relay email via 3rd party program), and it works manually, but if I run it via task scheduler, the variables don't copy over to the script, so I'm a little stumpted

The Batch File:
D:\smtpscript\KIX32.EXE D:\smtpscript\ipbatchupdate.kix
PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-ReceiveConnector EXCH01\RelayByScript -RemoteIPRanges %xline%"

The Kix Script:
IF Open(1, "\\exch01\smtpscript\clients.txt") = 0
  "File open"?
  $rline = ReadLine(1)
  $Xline = ""
  WHILE @ERROR = 0
    "Line read  = " + $rline?
    $xline=$xline + $rline + ","
    $rline = ReadLine(1)
  LOOP?
  $xline=$xline + "10.46.20.213"
  Close(1)?
ENDIF?
  $xline?
  set "xline=$xline"?
exit?

So I found a PS script and it seems to read the addresses, but I get the error:
WARNING: The command completed successfully but no settings of 'EXCH01\RelayByScript' have been modified.

PS Script:
$listIP = Get-Content .\Clients.txt
foreach($ipAdd in $listIP)
{
    $hubRe = Get-ReceiveConnector EXCH01\RelayByScript
    $hubRe.RemoteIPRanges += $ipAdd
    $hubRe | Set-ReceiveConnector
}

Any ideas?




Viewing all articles
Browse latest Browse all 8820

Trending Articles



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