| title | Track OS Deployment Migrations |
|---|---|
| description | The StoreCreationDate, StoreDeletionDate, and StoreReleaseDate properties can be used to identify the current state of the migration. |
| ms.date | 09/20/2016 |
| ms.subservice | sdk |
| ms.topic | how-to |
| ms.collection | tier3 |
You track Configuration Manager operating system migrations by inspecting the SMS_StateMigration class.
The StoreCreationDate, StoreDeletionDate, and StoreReleaseDate properties can be used to identify the current state of the migration.
-
Set up a connection to the SMS Provider. For more information, see SMS Provider fundamentals.
-
Get an instance of SMS_StateMigration.
-
Calculate the current migration state using the
StoreCreationDate,StoreDeletionDate, andStoreReleaseDateproperties.
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 Subpublic 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;
}
}The example method has the following parameters:
| Parameter | Type | Description |
|---|---|---|
connection |
- Managed: WqlConnectionManager- VBScript: SWbemServices |
A valid connection to the SMS Provider. |
The C# example has the following compilation requirements:
System
System.Collections.Generic
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
For more information about error handling, see About Configuration Manager Errors.
For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.
Objects overview 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 About OS deployment computer management