在 Configuration Manager 中,您可以設定作系統部署狀態移轉點,藉由設定 SMPQuiesceState 內嵌屬性來拒絕儲存用戶數據的新要求。
SMPQuiesceState 有兩個可能的值。
值 | 定義 |
---|---|
0 | 僅限還原模式已關閉。 |
1 | 已開啟僅還原模式。 |
設定狀態移轉點的僅還原模式
設定與SMS提供者的連線。 如需詳細資訊,請 參閱SMS提供者基本概念。
線上至月臺控制檔的狀態移轉點資源區段。
取得內嵌屬性。
更新 SMPQuiesceState。
將變更認可至月臺控制檔案。
範例
下列範例方法會根據提供的值設定僅還原模式。
如需呼叫範例程式代碼的相關信息,請參閱呼叫 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;
}
}
範例方法具有下列參數:
參數 | Type | 描述 |
---|---|---|
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 |
設定僅限還原模式。 - Managed: true 開啟僅限還原模式,否則 false 為 。- VBScript: 1 開啟還原模式,否則 0 為 。 |
正在編譯程式碼
C# 範例具有下列編譯需求:
命名空間
系統
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
組件
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
健全的程式設計
如需錯誤處理的詳細資訊,請參閱關於 Configuration Manager 錯誤。
.NET Framework 安全性
如需保護 Configuration Manager 應用程式的詳細資訊,請參閱 Configuration Manager 角色型系統管理。
另請參閱
關於 OS 部署月臺角色設定如何使用 Managed 程式代碼讀取和寫入 Configuration Manager 月臺控制檔案如何使用 WMI 讀取和寫入 Configuration Manager 月臺控制檔案