CheckAndCall(arg) Function CheckAndCall(arg) set argList = WScript.Arguments if argList.length < 7 or argList.length > 7 Then rem Do Nothing, just exit returnCode = 1 else rem get the arguments into variables success = argList(0) failure = argList(1) failureid1 = argList(2) failureid2 = argList(3) failureid3 = argList(4) successflag = argList(5) successid1 = argList(6) set oShell =createobject("wscript.shell") on error resume next oShell.RegRead "HKLM\SYSTEM\CurrentControlSet\Services\WinRM\ImagePath" if Err Then rem If we don't find the key there will be an error Err.Clear WScript.Echo "WinRM not found" WScript.Echo "Status=" & failure WScript.Echo "DescriptionID=" & failureid1 else args = "winrm id -format:xml >%temp%\winrmidlog" errTrap = oShell.run (args, 7, True) WScript.Echo "errTrap = "& errTrap Set fso = CreateObject("Scripting.FileSystemObject") Set tfolder = fso.GetSpecialFolder(2) Set xmlDoc = CreateObject("MSXml2.DOMDocument.3.0") WScript.Echo tfolder&"\winrmidlog" xmlDoc.load tfolder&"\winrmidlog" Set ret = xmlDoc.getElementsByTagName("wsmid:ProductVersion").item(0) WScript.Echo ret.text If 0=InStr(1, ret.text, "Stack: 1.1",VBTextCompare) and 0=InStr(1, ret.text, "Stack: 2.0",VBTextCompare) and 0=InStr(1, ret.text, "Stack: 3.0",VBTextCompare) Then WScript.Echo "WinRM version is not 1.1, 2.0 or 3.0" WScript.Echo "Status=" & failure WScript.Echo "DescriptionID=" & failureid2 Else ' WScript.Echo "Required WinRM version Found" Set objWRM = CreateObject("WSMan.Automation") Set objSession = objWRM.CreateSession strResource = "http://schemas.microsoft.com/wbem/wsman/1/config/listener" Set objResponse = objSession.Enumerate(strResource) boolHTTPSFlag = 0 Do Until objResponse.AtEndOfStream Set xmlFile = CreateObject("MSXml2.DOMDocument.3.0") xmlFile.LoadXml(objResponse.ReadItem) Set trn = xmlFile.getElementsByTagName("cfg:Transport").item(0) Set port = xmlFile.getElementsByTagName("cfg:Port").item(0) boolHTTPSFlag = HasHTTPSLtn ( trn.text ) boolPORTFlag = HasPortEnabled( port.text ) Loop If boolHTTPSFlag = 0 or boolPORTFlag = 0 Then Wscript.Echo "WinRM version is Correct but HTTPS Listener is not enabled" WScript.Echo "Status=" & failure WScript.Echo "DescriptionID=" & failureid3 ElseIf boolHTTPSFlag = 1 and boolPORTFlag = 1 Then Wscript.Echo "WinRM version is Correct and HTTPS Listener is enabled" WScript.Echo "Status=" & successflag WScript.Echo "DescriptionID=" & successid1 End If end If end if end if End Function Function HasHTTPSLtn (strTransport ) Select Case strTransport Case "HTTPS" HasHTTPSLtn = 1 Case "HTTP" HasHTTPSLtn = 0 Case Else HasHTTPSLtn = 0 End Select End Function Function HasPortEnabled (strPort ) Select Case strPort Case "443" HasPortEnabled = 1 Case Else HasPortEnabled = 0 End Select End Function