共用方式為


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

Autopilot 用戶驅動Microsoft加入步驟:

  • 步驟 3:建立 Autopilot 配置檔的 JSON 檔案

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

建立 Autopilot 配置檔的 JSON 檔案

注意事項

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

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

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

  1. 登入 Configuration Manager 月台伺服器或其他裝置,其中已在安裝 必要的模塊中安裝必要的模組,以從 Intune 取得 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 和 Autopilot 配置檔的 Microsoft Entra 帳戶登入。

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

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

注意事項

上述腳本會從 Intune 導出所有 Autopilot 配置檔。 除了支援的使用者驅動 Autopilot 配置檔之外,它也會下載不支援的預先布建 Autopilot 配置檔,並在環境中存在 Autopilot 配置檔時自行部署。

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

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