Skip to content

Instantly share code, notes, and snippets.

@junecastillote
Last active July 10, 2019 05:55
Show Gist options
  • Save junecastillote/3a4bc3c1b5a00f0dc103ada2cf2c8807 to your computer and use it in GitHub Desktop.
Save junecastillote/3a4bc3c1b5a00f0dc103ada2cf2c8807 to your computer and use it in GitHub Desktop.
How to use:
1. Copy / Save the code as ExportIISAllowedRelayIP.vbs
2. Open Command Prompt.
3. Change directory to where the sript is saved.
4. Run this command:
cscript //nologo ExportIISAllowedRelayIP.vbs
' Output file for report
fileOutput = "Allow_RelayIP.txt"
' The Vitual SMTP Server ID
vistualSMTPServer = "IIS://localhost/smtpsvc/1"
Set fso = CreateObject("Scripting.FileSystemObject")
Set allowFile = fso.opentextfile(fileOutput,2,true)
Set objSMTP = GetObject(vistualSMTPServer)
Set objRelayIpList = objSMTP.Get("RelayIpList")
objCurrentList = objRelayIpList.IPGrant
i = 0
For Each objIP in objCurrentList
arrayFields = Split(objIP, ", ")
allowFile.WriteLine arrayFields(0)
Wscript.Echo arrayFields(0)
i = i + 1
Next
Wscript.Echo "Saved in " & fileOutput
If i = 0 Then
Wscript.Echo "No entries found"
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment