使用PowerShell建立新的服務主體

技術文章

Solution
Application
Content Type
技術說明文件
Utilities & Services
ft:locale
zh-TW

有關如何在Jamf Pro介面中配置SMTP伺服器設定的說明,請參閱Jamf Pro 說明文件中的SMTP伺服器整合

  1. 開啟PowerShell。
  2. 執行以下命令以匯入ExchangeOnlineManagement課程單元:
    Import-module ExchangeOnlineManagement
    
    注意:

    如果PowerShell傳回「找不到課程單元」錯誤,您可能需要安裝課程單元才能繼續。如需更多資訊,請參閱下列Microsoft說明文件:關於Exchange Online PowerShell課程單元

  3. 執行命令來定義PowerShell要使用的變數。使用您在本文的在Microsoft Entra中為Jamf Pro建立App註冊和在Exchange管理員中心配置權限一節中收集的變數完成命令。
    • $Tenant後,輸入租用戶ID。

    • $ClientId=後,輸入用戶端ID。

    • $ServicePrincipal=後,輸入服務主體物件ID。

    • $EmailGroupId=後,輸入您想要傳送電子郵件的電子郵件地址。

    $Tenant='0344bcc1-e70b-4ff4-0000-922cb9a226a7';
    $ClientId='a8fc014b-3a7c-495e-8998-b945b225d4ff';
    $ServicePrincipal='f2cddd66-67f6-42fb-9827-fec98920984a'; 
    $EmailGroupId='jamfpro@example.com'; 
    
                            
  4. 執行以下命令將PowerShell連線到Exchange Online。出現提示時,輸入具有組織管理憑證的Exchange帳戶的憑證。
    Connect-ExchangeOnline -Organization $Tenant 
    
  5. 執行以下命令以啟用組織自訂:
    Enable-OrganizationCustomization 
    
    注意:

    為了執行本區段的步驟,必須在租用戶中啟用Enable-OrganizationCustomization設定。若要驗證,請執行以下命令:

    Get-OrganizationConfig | fl Identity, IsDehydrated

    如果PowerShell傳回值False,則租用戶配置正確。繼續執行本區段中的步驟。

    如果PowerShell傳回值True,請在繼續之前執行下列命令:

    Enable-OrganizationCustomization
  6. 執行以下命令以建立新的服務主體:
     New-ServicePrincipal -AppId $ClientId -ObjectId $ServicePrincipal -DisplayName "Service Principal" 
    
  7. 執行以下命令,為啟用郵件功能的安全性群組建立用於傳送郵件的角色:
    New-ManagementRoleAssignment -App $ClientId -Role "Application Mail.Send" -RecipientGroupScope $EmailGroupId