How to Track Operating System Deployment Migrations in Configuration Manager
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
You track System Center 2012 R2 Configuration Manager operating system migrations by inspecting the SMS_StateMigration Server WMI Class class.
The StoreCreationDate, StoreDeletionDate, and StoreReleaseDate properties can be used to identify the current state of the migration.
To track state migrations
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Get an instance of SMS_StateMigration.
Calculate the current migration state using the StoreCreationDate, StoreDeletionDate, and StoreReleaseDate properties.
Example
The following example method enumerates through all migrations and determines whether they are in progress.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub MigrationState(connection)
Dim migrations
Dim migration
Dim inProgress
Dim zeroTime
zeroTime = "00000000000000.000000+***"
Set migrations = connection.ExecQuery( "Select * From SMS_StateMigration")
For Each migration in Migrations
inProgress=False
If migration.StoreCreationDate<>zeroTime Then
If migration.StoreReleaseDate = zeroTime Then
inProgress=True
Else If migration.StoreDeletionDate = zeroTime Then
inProgress = True
Else
inProgress = false
End If
End If
Else
inProgress=False
End If
WScript.StdOut.Write "Migration " + migration.MigrationID
If inProgress = True Then
Wscript.Echo " is in progress"
Else
WScript.Echo " is not in progress"
End If
Next
End Sub
public void MigrationState(WqlConnectionManager connection) { try { IResultObject migrations = connection.QueryProcessor.ExecuteQuery("Select * from SMS_StateMigration"); string zeroTime = "00000000000000.000000+***"; foreach (IResultObject migration in migrations) { Boolean inProgress = false; if (migration["StoreCreationDate"].DateTimeValue.Equals(zeroTime) == false) { if (migration["StoreReleaseDate"].DateTimeValue.Equals(zeroTime) == true) { inProgress = true; } else if (migration["StoreDeletionDate"].DateTimeValue.Equals(zeroTime) == true) { inProgress = true; } else { inProgress = false; } } else { inProgress = false; } Console.Write("Migration " + migration["MigrationID"].StringValue); if (inProgress) { Console.WriteLine(" is in progress"); } else { Console.WriteLine(" is not in progress"); } } } catch (SmsException e) { Console.WriteLine("Failed while displaying migration state: " + e.Message); throw; } }
Compiling the Code
The C# example has the following compilation requirements:
System
System.Collections.Generic
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
.NET Framework Security
For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.
Configuration Manager Operating System Deployment
Configuration Manager Objects
Configuration Manager Programming Fundamentals
How to Connect to an SMS Provider in Configuration Manager by Using Managed Code
How to Connect to an SMS Provider in Configuration Manager by Using WMI
Operating System Deployment Computer Management
The example method has the following parameters:
Parameter
Type
Description
connection
Managed: WqlConnectionManager
VBScript: SWbemServices
A valid connection to the SMS Provider.