How to Clear a PXE Advertisement For a Configuration Manager Collection
Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2
To clear a PXE advertisement for a Microsoft System Center Configuration Manager 2007 collection, you call the ClearLastNBSAdvForCollection Method in Class SMS_Collection method.
Clearing a PXE advertisement forces the PXE server to re-evaluate the mandatory advertisement that a PXE device must execute on the next PXE boot. It is most often used when the last advertisement that was executed failed or when the advertisement must be re-run. For information about clearing the PXE advertisement for a resource, see How to Clear a PXE Advertisement for a Configuration Manager Resource.
To clear a PXE advertisement for a collection
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Get the SMS_Collection object for the collection you want to clear the PXE advertisement for.
Call the ClearLastNBSAdvForCollection method to clear the PXE advertisement for the collection.
Example
The following example clears the PXE advertisement for the collection that is identified by the collectionID parameter.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub ClearPxeAdvertisementCollection (connection, collectionID)
On Error Resume Next
Dim collection
' Get the collection.
Set collection = connection.Get("SMS_Collection.CollectionID='" & collectionID & "'")
result = collection.ClearLastNBSAdvForCollection
if Err.number <> 0 Then
WScript.Echo "Failed to clear PXE advertisement for collection: " & collectionID
Exit Sub
End If
End Sub
public void ClearPxeAdvertisementCollection(WqlConnectionManager connection, string collectionID)
{
try
{
// Get the collection.
IResultObject collection = connection.GetInstance(@"SMS_Collection.CollectionID='" + collectionID + "'");
Dictionary<string, object> inParams = new Dictionary<string, object>();
IResultObject outParams = collection.ExecuteMethod("ClearLastNBSAdvForCollection", inParams);
if (outParams == null || outParams["StatusCode"].IntegerValue != 0)
{
Console.WriteLine
("Failed to clear PXE advertisement for collection " + collection["Name"].ToString());
return;
}
}
catch (SmsException e)
{
Console.WriteLine("Failed to clear PXE advertisement " + e.Message);
}
}
The example method has the following parameters:
Parameter |
Type |
Description |
connection |
|
A valid connection to the SMS Provider. |
collectionID |
|
The resource identifier. You can obtain this from the SMS_Collection class CollectionID property. |
Compiling the Code
The C# example has the following compilation requirements:
Namespaces
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
Security
For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.
See Also
Concepts
How to Clear a PXE Advertisement for a Configuration Manager Resource