`
lovnet
  • 浏览: 6715666 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

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 <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>WMI SDK.

To create an SMS object

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

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

  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Create an instance of an SMS object by using the <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Save the SMS object by using the <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    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. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Delete the SMS object instance by using the SMS object class <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>Delete_ method. For example, to delete the advertisement object opened in step 1, use the following code:

    objAdvertisement.Delete_ 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics