使用脚本和程序创建WMI类和实例来扩展hardware inventory
来源:互联网 发布:苹果解压软件下载 编辑:程序博客网 时间:2024/06/05 10:14
MOF和MIF一样,也是文本文件,用脚本和程序创建很容易。麻烦在于要mofcomp编译到WMI中去,这个动作通过package部署当然也能做,但是不如直接将MOF类和实例信息通过脚本和程序写入WMI.
SMS 2003 SDK 中包括一个 VB程序 "Asset wizard“,提示用户输入资产相关的各种信息,然后写入WMI来扩展hinv。以下是其中的主要代码(存到vbs中可以直接运行),演示了写数据到 WMI 中的步骤,但不包括收集数据(SMS_def.mof报告类). 这个例子中,数据就在脚本中,当然也可以使用数据源,例如数据库来提取需要的数据。脚本的工作流程一目了然,就不解释了。WMI的概念,工具和编程不是本文的范围,有机会再讨论。
Set loc = CreateObject("WbemScripting.SWbemLocator")
Set WbemServices = loc.ConnectServer(, "root/CIMv2")
On Error Resume Next
Set WbemObject = WbemServices.Get("SMS_AssetWizard_1")
'If this call failed, we need to make the SMS_AssetWizard_1 data class
If Err Then
'Retrieve blank class
Set WbemObject = WbemServices.Get
'Set class name
WbemObject.Path_.Class = "SMS_AssetWizard_1"
'Add Properties (8 = CIM_STRING, 11 = CIM_BOOLEAN)
WbemObject.Properties_.Add "Type", 19
WbemObject.Properties_.Add "ContactFullName", 8
WbemObject.Properties_.Add "ContactEmail", 8
WbemObject.Properties_.Add "ContactPhone", 8
WbemObject.Properties_.Add "ContactLocation", 8
WbemObject.Properties_.Add "SysLocationSite", 8
WbemObject.Properties_.Add "SysLocationBuilding", 8
WbemObject.Properties_.Add "SysLocationRoom", 8
WbemObject.Properties_.Add "SysUnitManufacturer", 8
WbemObject.Properties_.Add "SysUnitModel", 8
WbemObject.Properties_.Add "SysUnitAssetNumber", 8
WbemObject.Properties_.Add "SysUnitIsLaptop", 11
'Add key qualifier to Type property
WbemObject.Properties_("Type").Qualifiers_.Add "key", True
WbemObject.Put_
End if
On Error Goto 0
Set WbemServices = loc.ConnectServer(, "root/CIMv2")
Set WbemObject = WbemServices.Get("SMS_AssetWizard_1").SpawnInstance_
' Store property values (the data!)
WbemObject.Type = 0
WbemObject.ContactFullName = "John Smith"
WbemObject.ContactEmail = "JSmith"
WbemObject.ContactPhone = "(425) 707-9791"
WbemObject.ContactLocation = "Redmond"
WbemObject.SysLocationSite = "Campus"
WbemObject.SysLocationBuilding = "24"
WbemObject.SysLocationRoom = "1168"
WbemObject.SysUnitManufacturer = "Dell"
WbemObject.SysUnitModel = "GX1"
WbemObject.SysUnitAssetNumber = "357701"
WbemObject.SysUnitIsLaptop = False
'WMI will overwrite the existing instance
WbemObject.Put_
下面是应该添加到 SMS_def.mof 中的报告类,用来hinv以上的数据。
#pragma namespace("////.//ROOT//CIMV2//sms")
[SMS_ReporT(TRUE),
SMS_Group_Name("Asset Wizard Results"),
SMS_Class_ID("MICROSOFT|ASSETWIZARD|1.0")]
class SMS_AssetWizard_1 : SMS_Class_Template
{
[SMS_Report(TRUE),key] uint32 Type;
[SMS_Report(TRUE)] string ContactFullName;
[SMS_Report(TRUE)] string ContactEmail;
[SMS_Report(TRUE)] string ContactPhone;
[SMS_Report(TRUE)] string ContactLocation;
[SMS_Report(TRUE)] string SysLocationSite;
[SMS_Report(TRUE)] string SysLocationBuilding;
[SMS_Report(TRUE)] string SysLocationRoom;
[SMS_Report(TRUE)] string SysUnitManufacturer;
[SMS_Report(TRUE)] string SysUnitModel;
[SMS_Report(TRUE)] string SysUnitAssetNumber;
[SMS_Report(TRUE)] boolean SysUnitIsLaptop;
};
- 使用脚本和程序创建WMI类和实例来扩展hardware inventory
- 使用NOIDMIF来扩展 hardware inventory
- 使用IDMIF来扩展 hardware inventory
- 使用MOF来扩展hardware inventory -- 静态数据
- 使用MOF来扩展hardware inventory -- 动态数据
- 使用MOF来扩展hardware inventory -- 动态数据 -- 补充
- 使用MOF来扩展hardware inventory -- 动态数据 -- 补充2 -- 其它名称空间中的信息的收集
- 【脚本】python中wmi介绍和使用
- 利用第三方工具扩展hardware inventory
- 使用WMI和Remoting的完美组合来实现在远程计算机上创建进程及与之通讯
- WMI和ManagementObjectSearcher一些使用
- WMI和ManagementObjectSearcher一些使用
- WMI和ManagementObjectSearcher一些使用
- jQuery类扩展和实例扩展
- 使用嵌套类来清晰化类接口,分离扩展操作和扩展查询。
- shell脚本来批量创建和删除数据库
- BizTalk: 使用 WMI 创建WCF-NetMsmq 接收端口和发送端口
- 如何使用DialogFragment类来创建和显示对话框
- SAA7121视频图像D/A转换芯片
- 西方哲学史 -- 阿那克西曼德
- Android的intent:基础以及显示/隐式使用Intent,SD挂载识别&& 通过intent返回结果
- 虚拟化实现业务连续性
- 格式化时间
- 使用脚本和程序创建WMI类和实例来扩展hardware inventory
- Makefile:3:***遗漏分隔符。停止 。原来如此.....
- socket的长.短连接!
- 待读 CString. stirng 区别及其转换
- 第二章,对象的创建与使用
- HTTP内容格式
- select 子句
- 双击打开文件夹却打开搜索文件夹,如何解决?
- No.7