Dim AllArgs Dim SplitArgs AllArgs = "" For Each Arg in WScript.Arguments AllArgs = AllArgs & Arg & " " Next AllArgs = RTrim(AllArgs) ' We don't know whether the user will have any spaces, quotes or double quotes in their input ' so we are using the section sign unicode character as a separator. SplitArgs = Split(AllArgs, "§") Wscript.Echo "Arguments given are:" For Each Arg in SplitArgs Wscript.Echo Arg Next Wscript.Echo "" If (uBound(SplitArgs) <> 8) Then WScript.Echo ("Error: expecting 8 arguments but found " & uBound(SplitArgs)) Else Dim URL Dim Body Dim Action, AlertName, AlertID, ObjectID, NodeName, NodeID, Severity ServiceKey = EscapeForJson(SplitArgs(1)) Action = EscapeForJson(SplitArgs(2)) AlertName = EscapeForJson(SplitArgs(3)) AlertID = EscapeForJson(SplitArgs(4)) ObjectID = EscapeForJson(SplitArgs(5)) NodeName = EscapeForJson(SplitArgs(6)) NodeID = EscapeForJson(SplitArgs(7)) Severity = EscapeForJson(SplitArgs(8)) set objHTTP = CreateObject("MSXML2.ServerXMLHTTP") URL = "https://events.pagerduty.com/generic/2010-04-15/create_event.json" Body = "{" &_ """service_key"": """ & ServiceKey & """," &_ """event_type"": """ & Action & """," &_ """description"": """ & AlertName & """," &_ """client"": ""SolarWinds""," &_ """incident_key"": """ & AlertID & "-" & ObjectID & """," &_ """details"":" &_ "{" &_ """alert_name"": """ & AlertName & """," &_ """node_name"": """ & NodeName & """," &_ """alert_id"": """ & AlertID & """," &_ """node_id"": """ & NodeID & """," &_ """severity"": """ & Severity & """," &_ """object_id"": """ & ObjectID & """" &_ "}" &_ "}" WScript.Echo "Body being sent to PagerDuty is: " & Body WScript.Echo "" objHTTP.open "POST", URL, false objHTTP.send Body WScript.Echo "Response from PagerDuty is: " & objHttp.responseText WScript.Echo "" End If Function EscapeForJson(Input) Dim BackSlashesEscaped, QuotesEscaped, TabsEscaped, NewLinesEscaped, VerticalTabEscaped Dim FormFeedEscaped, CarriageReturnEscaped, BackspacesEscaped BackSlashesEscaped = Replace(Input, "\", "\\") QuotesEscaped = Replace(BackSlashesEscaped, """", "\""") TabsEscaped = Replace(QuotesEscaped, vbTab, "\t") NewLinesEscaped = Replace(TabsEscaped, vbCrLf, "") VerticalTabEscaped = Replace(NewLinesEscaped, vbVerticalTab, "") FormFeedEscaped = Replace(VerticalTabEscaped, vbFormFeed, "") CarriageReturnEscaped = Replace(FormFeedEscaped, vbCr, "") BackspacesEscaped = Replace(CarriageReturnEscaped, vbBack, "") EscapeForJson = TabsEscaped End Function