Network Policy Server Client Configuration Discovery

Microsoft.NetworkPolicyServer.ClientDiscovery (Discovery)

Network Policy Server Client Configuration Discovery (netsh nps show client)

Knowledge Base article:

Summary

Discovery of the Client Configuration (netsh nps show client)

Element properties:

TargetMicrosoft.NetworkPolicyServer.NPSServers
EnabledTrue
Frequency28800
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.NetworkPolicyServer.ClientDiscovery" Enabled="true" Target="Microsoft.NetworkPolicyServer.NPSServers" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.NetworkPolicyServer.Configuration">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration">
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="Name"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="Address"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="State"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="Sharedsecret"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="Requireauthattrib"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="NAPcapable"/>
<Property TypeID="Microsoft.NetworkPolicyServer.ClientConfiguration" PropertyID="Vendor"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="Microsoft.NetworkPolicyServer.ConfigToClientConfigRelationship"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>28800</IntervalSeconds>
<SyncTime/>
<ScriptName>NPS-ClientConfig.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script><![CDATA['Script Start
'On Error Resume next
Dim oAPI, oArgs

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

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)

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 oClientConfig.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/Name$", cli.Name)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/Address$", cli.Address)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/State$", cli.State)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/Sharedsecret$", cli.Sharedsecret)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/Requireauthattrib$", cli.Requireauthattrib)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/NAPcapable$", cli.NAPcapable)
Call oClientConfig.AddProperty("$MPElement[Name='Microsoft.NetworkPolicyServer.ClientConfiguration']/Vendor$", cli.Vendor)
Call oClientConfig.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Client Configuration for " & cli.Name)

Call oDiscoveryData.AddInstance(oClientConfig)

Next

Call oAPI.Return(oDiscoveryData)

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>