状態移行ポイントのRestore-Only モードを設定する方法

Configuration Managerでは、SMPQuiesceState 埋め込みプロパティを設定して、ユーザー データを格納するための新しい要求を拒否するようにオペレーティング システムの展開状態移行ポイントを構成します。

SMPQuiesceState には、2 つの可能な値があります。

定義
0 復元専用モードはオフになっています。
1 復元専用モードが有効になっています。

状態移行ポイントの復元のみモードを設定するには

  1. SMS プロバイダーへの接続を設定します。 詳細については、「 SMS プロバイダーの基礎」を参照してください。

  2. サイト コントロール ファイルの状態移行ポイント リソース セクションに接続します。

  3. 埋め込みプロパティを取得します。

  4. SMPQuiesceState を更新します

  5. サイト コントロール ファイルに変更をコミットします。

次のメソッド例では、指定された値に基づいて復元専用モードを設定します。

サンプル コードの呼び出しについては、「Configuration Manager コード スニペットの呼び出し」を参照してください。

Sub SetRestoreOnlyMode(connection,          _  
                       context,           _  
                       siteCode,               _  
                       enableRestoreOnlyMode)  

    ' Load site control file and get SMS State Migration Point section.  
    connection.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , context  

    Query = "SELECT * FROM SMS_SCI_SysResUse " & _  
            "WHERE RoleName = 'SMS State Migration Point' " & _  
            "AND SiteCode = '" & siteCode & "'"  

    Set SCIComponentSet = connection.ExecQuery(Query, , , context)  

    ' Only one instance is returned from the query.  
    For Each SCIComponent In SCIComponentSet  

         ' Display state migration point server name.  
         wscript.echo "SMS State Migration Point Server: " & SCIComponent.NetworkOSPath                                      

        ' Loop through the array of embedded property instances.  
        For Each vProperty In SCIComponent.Props  

            ' Setting: SMPQuiesceState  
            If vProperty.PropertyName = "SMPQuiesceState" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value " &  vProperty.Value                 

                ' Modify the value.  
                vProperty.Value = enableRestoreOnlyMode  
                wscript.echo "New value " & enableRestoreOnlyMode  
            End If  

        Next     

             ' Update the component in your copy of the site control file. Get the path  
             ' to the updated object, which could be used later to retrieve the instance.  
             Set SCICompPath = SCIComponent.Put_( , context)  
    Next  

    ' Commit the change to the actual site control file.  
    Set InParams = connection.Get("SMS_SiteControlFile").Methods_("CommitSCF").InParameters.SpawnInstance_  
    InParams.SiteCode = siteCode  
    connection.ExecMethod "SMS_SiteControlFile", "CommitSCF", InParams, , context  
End Sub  
public void SetRestoreOnlyMode(  
    WqlConnectionManager connection,  
    string server,   
    string siteCode,   
    bool enableRestoreOnlyMode)  
{  
    try  
    {  
        // Get the site control file.  
        IResultObject ro = connection.GetInstance("SMS_SCI_SysResUse.FileType=2,ItemName='[\"Display=\\\\" + server + "\\\"]MSWNET:[\"SMS_SITE=" + siteCode + "\"]\\\\" + server + "\\,SMS State Migration Point',ItemType='System Resource Usage',SiteCode='" + siteCode + "'");  

        // Get the embedded properties.  
        Dictionary<string, IResultObject> embeddedProperties = ro.EmbeddedProperties;  

        // Set the restore only mode.  
        embeddedProperties["SMPQuiesceState"]["Value"].BooleanValue = enableRestoreOnlyMode;  

        ro.EmbeddedProperties = embeddedProperties;  

        // Commmit the changes.  
        ro.Put();  
    }  
    catch (SmsException e)  
    {  
        Console.WriteLine("Failed to set restore only mode" + e.Message);  
        throw;  
    }  
}  

このメソッドの例には、次のパラメーターがあります。

パラメーター 説明
connection -管理: WqlConnectionManager
- VBScript: SWbemServices
SMS プロバイダーへの有効な接続。
context (VBScript) -Vbscript: SWbemContext 有効なコンテキスト オブジェクト。 詳細については、「WMI を使用してConfiguration Managerコンテキスト修飾子を追加する方法」を参照してください。
server -管理: String
-Vbscript: String
状態移行ポイントが実行されているConfiguration Manager サーバー。
siteCode -管理: String
-Vbscript: String
Configuration Manager サイト コード。
enableRestoreOnlyMode -管理: Boolean
-Vbscript: Integer
復元のみのモードを設定します。

- マネージド: true 復元のみモードをオンにし、それ以外の場合 falseは をオンにします。
- VBScript: 1 復元モードをオンにします。それ以外の場合 0は 。

コードのコンパイル

C# の例には、次のコンパイル要件があります。

名前空間

System

System.Collections.Generic

System.text

Microsoft。ConfigurationManagement.ManagementProvider

Microsoft。ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

堅牢なプログラミング

エラー処理の詳細については、「Configuration Manager エラーについて」を参照してください。

.NET Framework のセキュリティ

Configuration Manager アプリケーションのセキュリティ保護の詳細については、「ロールベースの管理Configuration Manager」を参照してください。

関連項目

OS 展開サイトロールの構成についてマネージド コードを使用してConfiguration Manager サイト コントロール ファイルの読み取りと書き込みを行う方法
WMI を使用してConfiguration Manager サイト コントロール ファイルの読み取りと書き込みを行う方法