本節資訊可協助您判斷使用 Windows Server 移轉工具 Cmdlet 的移轉是成功或失敗。 如果失敗,則可以使用本節資訊協助您調查失敗原因。

疑難排解移轉

Windows Server 移轉工具 部署記錄檔位於 %windir%\Logs\SmigDeploy.log。其他 Windows Server 移轉工具 記錄檔則是建立在下列位置。

  • %windir%\Logs\ServerMigration.log

  • 在 Windows Server 2008 和 Windows Server 2008 R2 上: %localappdata%\SvrMig\Log

  • 在 Windows Server 2003 上: %userprofile%\Local Settings\Application Data\SvrMig\Log

如果無法在前述位置中建立移轉記錄檔,則 ServerMigration.logSmigDeploy.log 會建立於 %temp%,其他記錄檔則是建立於 %windir%\System32。

檢視 Windows Server 移轉工具結果物件的內容

所有 Windows Server 移轉工具 Cmdlet 都會將結果當成物件傳回。 您可以儲存結果物件,並查詢它們以取得所移轉之設定和資料的詳細資訊。 您也可以使用結果物件做為其他 Windows PowerShell 命令和指令碼的輸入。

結果物件描述

Windows Server 移轉工具 Import-SmigServerSettingExport-SmigServerSetting Cmdlet 會以 MigrationResult 物件清單的形式傳回結果。 每個 MigrationResult 物件都會包含 Cmdlet 所處理之資料或設定的資訊、操作結果以及任何相關錯誤或警告訊息。 下表描述 MigrationResult 物件的內容。

內容名稱類型定義

ItemType

列舉

所移轉項目的類型。 值包括 FileFolderRegistryKeyShareEncryptedFile

ID

字串

所移轉項目的識別碼。 值範例包括 Local UserLocal GroupDHCP

Success

布林值

如果移轉成功,會顯示值 True,否則會顯示 False

DetailsList

清單 <MigrationResultDetails>

MigrationResultDetails 物件的清單。

Send-SmigServerDataReceive-SmigServerData Cmdlet 會以 MigrationDataResult 物件清單的形式傳回結果。 每個 MigrationDataResult 物件都會包含 Cmdlet 所處理之資料或共用的資訊、操作結果、任何錯誤或警告訊息以及其他相關資訊。 下表描述 MigrationDataResult 物件的內容。

內容名稱類型定義

ItemType

列舉

所移轉項目的類型。 值包括 FileFolderShareEncrypted File

SourceLocation

字串

項目的來源位置 (以路徑名稱顯示)。

DestinationLocation

字串

項目的目的地位置 (以路徑名稱顯示)。

Success

布林值

如果移轉成功,會顯示值 True,否則會顯示 False

Size

整數

項目大小 (位元組)。

ErrorDetails

清單 <MigrationResultDetails>

單一 MigrationResultDetails 物件。

Error

列舉

所發生錯誤的錯誤列舉。

WarningMessageList

清單 <String>

警告訊息的清單。

下表描述 MigrationResultDetails 物件內同時適用於 MigrationResultMigrationDataResult 物件的物件內容。

內容名稱類型定義

Id

字串

與項目相關之移轉設定的名稱。 值範例包括 IPConfigDNS。 資料移轉的這個內容是空的。

Messages

清單 <String>

詳細事件訊息的清單。

DetailCode

整數

與每個事件訊息關聯的錯誤碼或警告碼。

Severity

列舉

所發生事件的嚴重性。 值範例包括 InformationErrorWarning

Title

字串

結果物件的標題。 值範例包括進行 IP 設定的 NIC 實體位址,或進行本機使用者移轉的使用者名稱。

範例

下列範例顯示如何將結果物件的清單存放到變數,然後在查詢中使用這個變數,以在移轉完成之後傳回結果物件的內容。

將結果物件的清單以查詢的變數存放
  1. 若要執行 Cmdlet,並將結果儲存到變數中,請以下列格式輸入命令,然後按 Enter 鍵。

    $VariableName = $(Cmdlet)

    範例如下。

    $ImportResult = $(Import-SmigServerSetting -FeatureId DHCP -User all -Group -Path D:\rmt\DemoStore -force –Verbose)

    這個命令執行已指定多個參數的 Import-SmigServerSetting Cmdlet,然後將結果物件儲存到變數 ImportResult 中。

  2. Import-SmigServerSetting Cmdlet 完成操作之後,以下列格式輸入命令,然後按 Enter 鍵,就會傳回結果物件內所含的資訊。

    $VariableName

    在下列範例中,變數的名稱為 ImportResult

    $ImportResult

    這個命令會傳回步驟 1 所顯示範例之 Import-SmigServerSetting 傳回的結果物件所含的資訊。下列是呼叫 ImportResult 變數所顯示的輸出範例。

               ItemType  ID                              Success  DetailsList
               --------  --                              -------  -----------
              OSSetting  Local User                         True  {Local User, Loc...
              OSSetting  Local Group                        True  {Local Group, Lo...
         WindowsFeature  DHCP                               True  {}
    

    前一個範例的每一行都是使用 Import-SmigServerSetting Cmdlet 所移轉項目的移轉結果。 欄位表頭名稱就是 MigrationResult 物件的內容。 您可以將這些內容併入另一個命令中,以傳回結果物件的較詳細資料 (如步驟 3 和之後的步驟所示)。

  3. 若要顯示清單中所有結果物件的特定內容,請以下列格式輸入命令,然後按 Enter 鍵。

    $<VariableName>| Select-Object -ExpandProperty <PropertyName>

    範例如下。

    $importResult | Select-Object -ExpandProperty DetailsList
  4. 您可以使用 Windows PowerShell Cmdlet 來執行更進階的查詢以分析結果物件。 範例如下。

    • 下列命令只會傳回識別碼為 Local User 之結果物件的詳細資料。

      $ImportResult | Where-Object { $_.ID -eq "Local User" } | Select-Object -ExpandProperty DetailsList
    • 下列命令只會傳回識別碼為 Local User 且訊息嚴重性等於 Warning 之結果物件的詳細資料。

      $ImportResult | Where-Object { $_.ID -eq "Local User" } | Select-Object -ExpandProperty DetailsList | ForEach-Object { if ($_.Severity -eq "Warning") {$_} }
    • 下列命令只會傳回識別碼為 Local User 且標題為 Remote Desktop Users 之結果物件的詳細資料。

      $ImportResult | Where-Object { $_.ID -eq "Local Group" } | Select-Object -ExpandProperty DetailsList | ForEach-Object { if ($_.Title -eq "Remote Desktop Users") {$_} }

查詢結果的詳細資訊

如需用於先前範例之 Cmdlet 的相關資訊,請參閱下列其他資源。

如需 Windows PowerShell 指令碼技術的相關資訊,請參閱 Microsoft Script Center 網站上的如何使用 Windows PowerShell?- 指令碼技術 (可能為英文網頁) (https://go.microsoft.com/fwlink/?LinkId=134862)。