แชร์ผ่าน


บทช่วยสอน: สร้างรายงานการแยกข้ามผู้เช่า (พรีวิว)

[บทความนี้เป็นคู่มือรุ่นก่อนวางจำหน่าย และอาจจะมีการเปลี่ยนแปลงในอนาคต]

บทช่วยสอนนี้สาธิตวิธีใช้ 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 อ้างถึง - รายงานการเชื่อมต่อข้ามผู้เช่า