分享方式:


教學課程:建立跨租用戶隔離報告 (預覽版)

[本文章是發行前版本文件,且隨時可能變更。]

此教學課程將說明如何使用 Power Platform API (預覽版) 建立跨租用戶隔離報表。

在本教學課程中,您將了解如何:

  1. 使用 Power Platform API 驗證
  2. 建立報表
  3. 列出租用戶的所有報表
  4. 擷取單一報表

重要

  • 這是預覽功能。
  • 預覽功能不供生產時使用,而且可能功能受限。 這些功能是在正式發行前先行推出,讓客戶能夠搶先體驗並提供意見反應。
  • 在此功能預覽期間,主機名稱和資料協定可能會變更。
  • 如需有關租用戶隔離的詳細資訊,請參閱跨租用戶入站和出站限制

步驟 1: 使用 Power Platform API 驗證

使用下列 PowerShell 指令碼透過 Power Platform API 進行驗證。

注意

只有具有全域管理員和 Power Platform 管理員 Entra ID 角色的使用者才有權執行租用戶隔離影響報表。

Import-Module "MSAL.PS"
$AuthResult = Get-MsalToken -ClientId '49676daf-ff23-4aac-adcc-55472d4e2ce0' -Scope 'https://api.powerplatform.com/.default'
$Headers = @{Authorization = "Bearer $($AuthResult.AccessToken)"}

步驟 2: 建立報表

您可以使用以下 PowerShell 指令碼來建立報表。

附註

每個行事曆日只能為一個租用戶建立一份報表。

try 
{
    # Create a cross tenant connections report
    $tenantReportCreateResponse = Invoke-RestMethod -Method Post -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports?api-version=2022-03-01-preview" -Headers $Headers -Body ""
    $reportId = $tenantReportCreateResponse.reportId
    $reportStatus = $tenantReportCreateResponse.status

    Write-Host "Cross tenant connections report created with ID=$reportId and status=$reportStatus" 

} catch {
    # Dig into the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 參考:建立跨租用戶連線報表

步驟 3: 列出租用戶的所有報表

使用下列 PowerShell 指令碼列出租用戶的所有可用報表。

try 
{
     # Get all available cross tenant connections reports for a tenant
    $tenantListReportResponse = Invoke-RestMethod -Method Get -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports?api-version=2022-03-01-preview" -Headers $Headers
    $report = $tenantListReportResponse | ConvertTo-Json -Depth 3 
    Write-Host $report 

} catch {
    # Dig into the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 參考:取得跨租用戶連線報表

步驟 4. 擷取單一報表

使用下列 PowerShell 指令碼為您的租用戶取得有關租用戶內所使用連線的單一報表。

try 
{
   # Get one cross tenant connections report for a tenant
    $tenantListReportResponse = Invoke-RestMethod -Method Get -Uri "https://api.powerplatform.com/governance/crossTenantConnectionReports/{$reportId}?api-version=2022-03-01-preview" -Headers $Headers
    $report = $tenantListReportResponse | ConvertTo-Json -Depth 2 
    Write-Host $report
    Write-Host "" 

} catch {
    # Go through the exception to get the Response details.
    Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
    $result = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($result)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();

        Write-Host $responseBody
}

Power Platform API 參考:列出跨租用戶連線報表

請參閱

Power Platform API 參考 - 跨租用戶連線報表