One of the questions was about how to list all Policies assigned for certain node or all nodes
the answer was typically there is a default report built-in HP Reporter
This report is called OVO/Windows 7.5 ConfInstalledPol "OVO/Windows 7.5 Installed Policies per Node"
You can also rerun the report as Excel.
But the issue is sometimes you need a report for a certain node or all nodes and HP Reporter requires certain configuration (very easy) but I have given also another solution
To list all policies deployed on nodes based on latest Policy Synchronization
'//get the name of the managed node from the command lineDim argsObjSet argsObj=WScript.ArgumentsIf argsObj.Count=0 ThenWScript.echo "Usage: cscript.exe RedployAllPolicies.vbs <nodeNameList>"WScript.Quit (1)End If'//create connection to policy management serverDim PMADSet PMAD = CreateObject("PMAD.OvPmdPolicyManager")PMAD.ConnectDB'//access the managed node in WMIDim objLocatorSet objLocator = CreateObject("WbemScripting.SWbemLocator")Dim objNodeSet objNode = objLocator.ConnectServer("", "root\HewlettPackard\OpenView\data", "", "")objNode.Security_.impersonationlevel = 3'//iterate over the specified node listDim nodeNameDim numOfNodesFor numOfNodes = 0 To argsObj.Count - 1'//get the primary node name as it was specified on the command linenodeName = argsObj(numOfNodes)'//get the node from WMIDim msgQuerymsgQuery = "Select * from ov_managednode where primarynodename = """ & nodeName & """"Dim objNodeListSet objNodeList = objNode.ExecQuery(msgQuery)'//get the GUID of the managed node objectDim nodeGuidDim wmiNodeFor Each wmiNode In objNodeList'//assign the node GUID to the variable "nodeGuid"nodeGuid = wmiNode.Name'//other node properties, such as system type or OS type, can be determine the same way'//for example, osType = wmiNode.OSType or sysType = wmiNode.SystemType)Next'//release objectsSet wmiNode = NothingSet objNodeList = NothingIf PMAD.DBConnected And nodeGuid <> "" Then'//get the pmad node object, or create it if it does not yet exist)Dim nodeSet node = PMAD.CreateNode(nodeGuid)'//get the list of policies that are currently installed on the nodeDim policyListpolicyList = PMAD.CVar(node.GetPolicyList)WScript.echo "The following policies are redeployed on node '" & nodeName & "':" & vrLfDim policyDim policyObjDim policyStringFor Each policy In policyList'//get the policy objectSet policyObj = policy'//print out policy that is redployedpolicyString = " " & policyObj.GetName & " " & policyObj.GetVersionString & vrLfWScript.echo policyStringNextWScript.echo " " & vrLfSet policy = NothingSet policyList = NothingSet node = NothingElseIf nodeGuid = "" ThenWScript.echo "Error: The node '" & nodeName & "' that you specified on the command line cannot be found in WMI!"ElseWScript.echo "Error: Unable to connect to the policy management server!"End IfEnd IfNext'//release objectsSet objNode = NothingSet objLocator = NothingSet PMAD = Nothing
Typical usage: cscript.exe ListNodePolicies.vbs nodename
Also with a little modification to the script we can list all nodes
Here below of screenshot for the above script:Dim argsObjSet argsObj=WScript.ArgumentsIf argsObj.Count>0 ThenWScript.echo "Usage: cscript.exe ListAllNodesWithPolicies.vbs"WScript.Quit (1)End If'//create connection to policy management serverDim PMADSet PMAD = CreateObject("PMAD.OvPmdPolicyManager")PMAD.ConnectDB'//access the managed node in WMIDim objLocatorSet objLocator = CreateObject("WbemScripting.SWbemLocator")Dim objNodeSet objNode = objLocator.ConnectServer("", "root\HewlettPackard\OpenView\data", "", "")objNode.Security_.impersonationlevel = 3Dim nodeNameDim numOfNodesDim msgQuerymsgQuery = "Select * from ov_managednode"Dim objNodeListSet objNodeList = objNode.ExecQuery(msgQuery)Dim nodeGuidDim wmiNodeFor Each wmiNode In objNodeListnodeGuid = wmiNode.NamenodeName = wmiNode.primarynodenameIf PMAD.DBConnected And nodeGuid <> "" Then'//get the pmad node object, or create it if it does not yet exist)Dim nodeSet node = PMAD.CreateNode(nodeGuid)'//get the list of policies that are currently installed on the nodeDim policyListpolicyList = PMAD.CVar(node.GetPolicyList)WScript.echo "The following policies are redeployed on node '" & nodeName & "':" & vrLfDim policyDim policyObjDim policyStringFor Each policy In policyList'//get the policy objectSet policyObj = policy'//print out policy that is redployedpolicyString = " " & policyObj.GetName & " " & policyObj.GetVersionString & vrLfWScript.echo policyStringNextWScript.echo " " & vrLfSet policy = NothingSet policyList = NothingSet node = NothingElseIf nodeGuid = "" ThenWScript.echo "Error: The node '" & nodeName & "' that you specified on the command line cannot be found in WMI!"ElseWScript.echo "Error: Unable to connect to the policy management server!"End IfEnd IfNext
Some nodes displayed above without Policies because they are dummies I created for testing purposes.
5 comments:
Thanks Mahmoud...I am going to post the question on itrc fourum but thought to check ypur first and I got it....
Dharmendra
EventID: 0x00000400 (1024) - Messages are discarded because of duplicate nodes
in DB.
Please advise
how to display the contents of teh parm file in an AIX maanaged node from OMW 9 server?
Great effort :)
Thanks.
Lovely VB!! Thanks much Mahmoud.
Post a Comment