Compartilhar via


IUpdateServer.GetRootUpdateCategories Method ()

 

Applies To: Windows Server Update Services

Gets a collection of the top-level categories on the WSUS server.

Namespace:   Microsoft.UpdateServices.Administration
Assembly:  Microsoft.UpdateServices.Administration (in Microsoft.UpdateServices.Administration.dll)

Syntax

UpdateCategoryCollection GetRootUpdateCategories()
UpdateCategoryCollection^ GetRootUpdateCategories()
abstract GetRootUpdateCategories : unit -> UpdateCategoryCollection
Function GetRootUpdateCategories As UpdateCategoryCollection

Return Value

Type: Microsoft.UpdateServices.Administration.UpdateCategoryCollection

An UpdateCategoryCollection collection of the top-level categories on the WSUS server.

Remarks

A category can represent a company, product family, or product. The root category is the company category. The company category can have one or more subcategories known as product family categories. Product family categories contain one or more product categories. To determine the category's type, use Type. For example, the company category for Microsoft is Microsoft Corporation. The Microsoft Corporation category contains the Windows product family category, which in turn contains product categories, such as the Windows Server 2003 family.

Typically, you use this method to list the available product and product families for each company. The user can then select the products to which they want to subscribe. For details, see SetUpdateCategories.

To get all new categories that were added during a given period, call GetUpdateCategories.

Examples

The following example shows how to get all categories on the WSUS server. The server variable that is used in the example is an instance of IUpdateServer. For information about getting an IUpdateServer instance, see GetUpdateServer.

static void DisplayCategories(UpdateCategoryCollection categories)
{
   foreach (IUpdateCategory category in categories)
   {
      switch (category.Type)
      {
         case UpdateCategoryType.Company:
            Console.WriteLine();
            break;
         case UpdateCategoryType.ProductFamily:
            Console.Write("  ");
            break;
         case UpdateCategoryType.Company:
            Console.Write("    ");
            break;
      }
      Console.WriteLine("{0}", category.Title);
      if (category.ProhibitSubcategories == false) //no subcategories
      {
         DisplayCategories(category.GetSubcategories());
      }
   }
}

See Also

IUpdateServer Interface
Microsoft.UpdateServices.Administration Namespace

Return to top