Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = Wscript.Arguments
If oArgs.Count < 3 Then
Call oAPI.LogScriptEvent("NPS-ClientConfig.vbs", 101, 1, "NPS ClientConfig script was called with fewer than three arguments and was not executed.")
Wscript.Quit
end If
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Set oShell = CreateObject("WScript.Shell")
Set oQuery = oShell.Exec("netsh nps show client")
' If No client config exist quit the Script
Do while not oquery.StdOut.AtendOfStream
strline = oQuery.StdOut.ReadAll
if instr(1,strLine,"Client configuration: ",1) =< 0 then
Call oAPI.LogScriptEvent("NPS-ClientConfig.vbs", 100, 0, "No NPS Clients were found.")
WScript.Quit
end if
Loop
' There are client configs found; Run netsh again
Set oQuery = oShell.Exec("netsh nps show client")
' Create the application instance.
Set oHost = odiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.NetworkPolicyServer.Configuration']$")
' Define the property values.
Call oHost.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oHost.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "NPS Config on " & TargetComputer)
Call oDiscoveryData.AddInstance(oHost)
' Discover the Client Configuration
Dim Line, fields
Dim c
Set Clients = CreateObject("Scripting.Dictionary")
firstrun = True
Do while not oquery.StdOut.AtendOfStream
strline = oQuery.StdOut.ReadLine
If strLine = "Client configuration: " Then
If not firstrun then
clients.Add c.name, c
End if
Set c = new client
firstrun = False
Else
if instr(strline, "=") > 0 then
fields = Split(strLine,"=")
If inStr(1, fields(0),"Name") Then
c.name = trim(Fields(1))
elseif inStr(1, fields(0),"Address") Then
c.Address = trim(Fields(1))
elseif inStr(1, fields(0),"State") Then
c.State = trim(Fields(1))
elseif inStr(1, fields(0),"Shared secret") Then
c.Sharedsecret = trim(Fields(1))
elseif inStr(1, fields(0),"Require auth attrib") Then
c.RequireAuthAttrib = trim(Fields(1))
elseif inStr(1, fields(0),"NAP capable") Then
c.NAPCapable = trim(Fields(1))
elseif inStr(1, fields(0),"Vendor") Then
c.Vendor = trim(Fields(1))
End if
End if
End if
loop
If not firstrun then
clients.Add c.name, c
End if
For each name in clients
set cli = clients.item(name)
' Create the application Component instance.
Set oClientConfig = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']$")
' Define the property values for the class.
' The ailable properties are detemined by the
' Management Pack that defines the class.
Call oAPI.LogScriptEvent ("NPS-ClientConfig.vbs", 100, 0, "NPS ClientConfig script is finished.")
Class Client
public Name, Address, State, Sharedsecret, RequireAuthAttrib, NAPCapable, Vendor
End Class]]></Script></ScriptBody>
<TimeoutSeconds>60</TimeoutSeconds>
</DataSource>
</Discovery>