共用方式為


現有裝置的 Windows Autopilot 部署:建立 Windows Autopilot 設定檔的 JSON 檔案

Windows Autopilot 使用者驅動 Microsoft Entra 聯結步驟:

  • 步驟 3:建立 Windows Autopilot 設定檔的 JSON 檔案

如需現有裝置工作流程的 Windows Autopilot 部署概觀,請參閱 Intune 和 Configuration Manager 中現有裝置的 Windows Autopilot 部署

建立 Windows Autopilot 設定檔的 JSON 檔案

注意事項

本節中的 PowerShell 程式碼片段已於 2023 年 7 月更新,以使用 Microsoft Graph PowerShell 模組,而不是已取代的 AzureAD Graph PowerShell 模組。 第一次使用 Microsoft Graph PowerShell 模組時,可能需要核准 Microsoft Entra ID 中的其他許可權。 如需詳細資訊,請參閱 AzureAD重要:Azure AD Graph 淘汰和 PowerShell 模組淘汰

安裝適當的模組以允許從 Intune 匯出 Windows Autopilot 配置檔之後,下一個步驟是將 Windows Autopilot 配置檔匯出為 JSON 檔案。 JSON 檔案可用來在 Configuration Manager 中建立套件。

若要將 Windows Autopilot 配置檔匯出為 JSON 檔案,請遵循下列步驟:

  1. 登入 Configuration Manager 月臺伺服器或安裝必要模組以從 Intune 取得 Windows Autopilot 配置檔 步驟中安裝必要模組的其他裝置。

  2. 在裝置上,以系統管理員身分開啟 PowerShell 視窗,方法是以滑鼠右鍵按一下 [開始] 功能表,然後選取 [Windows PowerShell (管理員) /Windows 終端機 (管理員) ],然後在 [使用者帳戶控制] (UAC) 提示中選取 []。

  3. 選取下列 PowerShell 程式碼區塊右上角的 [複製],以複製下列命令:

    Connect-MgGraph -Scopes "Device.ReadWrite.All", "DeviceManagementManagedDevices.ReadWrite.All", "DeviceManagementServiceConfig.ReadWrite.All", "Domain.ReadWrite.All", "Group.ReadWrite.All", "GroupMember.ReadWrite.All", "User.Read"
    $AutopilotProfile = Get-AutopilotProfile
    $targetDirectory = "C:\Autopilot"
    $AutopilotProfile | ForEach-Object {
        New-Item -ItemType Directory -Path "$targetDirectory\$($_.displayName)"
        $_ | ConvertTo-AutopilotConfigurationJSON | Set-Content -Encoding Ascii "$targetDirectory\$($_.displayName)\AutopilotConfigurationFile.json"
    }
    
  4. 將命令貼到提升許可權的 PowerShell 視窗中,然後選取鍵盤上的 Enter 以執行命令。 如果提高許可權的 PowerShell 命令視窗尚未登入 Intune,則會出現 [登入您的帳戶] 視窗。 使用可存取 Intune 和 Windows Autopilot 配置檔的 Microsoft Entra 帳戶登入。

  5. 登入 Intune 之後,可能需要再次選取 Enter 才能執行程式碼區塊中的最後一個命令。

  6. 一旦所有命令都成功執行,Windows Autopilot 設定檔會出現在變數所 $targetDirectory 指定資料夾下的子資料夾中。 依預設,變數 $targetDirectoryC:\AutoPilot,但視需要可以將其變更為另一個位置。 子資料夾具有來自 Intune 的 Windows Autopilot 配置檔名稱。 如果有多個 Windows Autopilot 設定檔,則每個設定檔都有自己的子資料夾。 在每個資料夾中,都有一個名為 AutopilotConfigurationFile.json的 JSON 檔案。

注意事項

上述腳本會從 Intune 匯出所有 Windows Autopilot 配置檔。 除了支援的使用者驅動 Windows Autopilot 配置檔之外,它也會下載不支援的預先布建 Windows Autopilot 配置檔和自我部署 Windows Autopilot 配置檔 (如果存在於環境中)。

下一個步驟:在 Configuration Manager 中建立和散發 JSON 檔案的套件

如需建立 JSON 檔案的詳細資訊,請參閱下列文章: