SMS脚本节选四:创建,修改,删除SMS对象

The processes by which SMS objects are managed can be divided into the following categories: 

  • Creating an SMS object

  • Modifying an SMS object

  • Deleting an SMS object

  • Calling a method on an SMS object

For more information on creating and deleting WMI objects, see the text xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">WMI SDK.

To create an SMS object

  1. Connect to an SMS Provider, and get the SWbemServices object.

  2. Create an instance of an SMS object by using the text xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">SpawnInstance method supported by the desired class. For example, to create an instance of a package object (SMS_Package), use the following code:

    Set objNewPackage = objSWbemServices.Get("SMS_Package").SpawnInstance_()
  3. Populate the required properties. For example, the following code sets the properties for a package:

    objNewPackage.Name = "Package Name"
    objNewPackage.Description = "A new package"
    objNewPackage.PkgSourceFlag = 2
    objNewPackage.PkgSourcePath = "C:/temp"
  4. Save the SMS object by using the text xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Put_ method supported by the SMS object class. For example, the following line of code puts or saves a package:

    objNewPackage.Put_
    

To modify an SMS object

  1. Get the instance of the required SMS object by using the Windows Script Host GetObject method and supplying the path to the required object. For example, to get an instance of an advertisement object (SMS_Advertisement) identified as 99920002, use the following code.

    Set objAdvertisement = GetObject( "WinMgmts:root/SMS/site_999:SMS_Advertisement.AdvertisementID='99920002'")
  2. Set the required properties of the SMS object. To enable the assigned schedule for an advertisement object, set the AssignedScheduledEnabled property to True, as in the following example:

    objAdvertisement.AssignedScheduleEnabled=True
  3. Update the SMS object by using the SMS object class Put method. For example, to update the advertisement opened in step 1, use the following code:

    objAdvertisement.Put_

To delete an SMS object

  1. Get the instance of the required SMS object by using GetObject and supplying the path to the required object. For example, to get an instance of an advertisement object (SMS_Advertisement) identified as 99920003, use the following code:

    Set objAdvertisement = GetObject( "WinMgmts:root/SMS/site_999:SMS_Advertisement.AdvertisementID='99920003'")
  2. Delete the SMS object instance by using the SMS object class text xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Delete_ method. For example, to delete the advertisement object opened in step 1, use the following code:

    objAdvertisement.Delete_ 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值