Dela via


Så här ställer du in Restore-Only läge för en tillståndsmigreringsplats

I Configuration Manager konfigurerar du migreringsplatsen för operativsystemets distributionstillstånd för att avvisa nya begäranden om att lagra användardata genom att ange den inbäddade egenskapen SMPQuiesceState.

SMPQuiesceState har två möjliga värden.

Värde Definition
0 Läget Endast återställning är inaktiverat.
1 Läget Endast återställning är aktiverat.

Så här ställer du in läget endast återställning för en tillståndsmigreringsplats

  1. Konfigurera en anslutning till SMS-providern. Mer information finns i grunderna för SMS-provider.

  2. Upprätta en anslutning till avsnittet tillståndsmigreringsplatsresurser i platskontrollfilen.

  3. Hämta de inbäddade egenskaperna.

  4. Uppdatera SMPQuiesceState.

  5. Checka in ändringarna i platskontrollfilen.

Exempel

Följande exempelmetod anger läget för endast återställning baserat på angivet värde.

Information om hur du anropar exempelkoden finns i Anropa Configuration Manager kodfragment.

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;  
    }  
}  

Exempelmetoden har följande parametrar:

Parameter Typ Beskrivning
connection -Hanterade: WqlConnectionManager
– VBScript: SWbemServices
En giltig anslutning till SMS-providern.
context (VBScript) -Vbscript: SWbemContext Ett giltigt kontextobjekt. Mer information finns i How to Add a Configuration Manager Context Qualifier by Using WMI (Lägga till en Configuration Manager kontextkvalificerare med hjälp av WMI).
server -Hanterade: String
-Vbscript: String
Den Configuration Manager server som tillståndsmigreringsplatsen körs på.
siteCode -Hanterade: String
-Vbscript: String
Configuration Manager platskod.
enableRestoreOnlyMode -Hanterade: Boolean
-Vbscript: Integer
Anger läget endast återställning.

– Hanterad: true aktiverar endast återställningsläge, annars false.
– VBScript: 1 aktiverar återställningsläget, annars 0.

Kompilera koden

C#-exemplet har följande kompileringskrav:

Namnområden

System

System.Collections.Generic

System.Text

Microsoft. ConfigurationManagement.ManagementProvider

Microsoft. ConfigurationManagement.ManagementProvider.WqlQueryEngine

Församlingen

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust programmering

Mer information om felhantering finns i Om Configuration Manager fel.

.NET Framework Säkerhet

Mer information om hur du skyddar Configuration Manager program finns i Configuration Manager rollbaserad administration.

Se även

Om konfiguration av platsrollen för operativsystemdistributionSå här läser och skriver du till Configuration Manager platskontrollfil med hjälp av hanterad kod
Läsa och skriva till Configuration Manager platskontrollfil med hjälp av WMI