แชร์ผ่าน


บทช่วยสอน: สร้างรายงานการแยกผู้เช่าระหว่างกัน

บทช่วยสอนนี้แสดงวิธีใช้ Power Platform API เพื่อสร้างรายงานการแยกผู้เช่าระหว่างกัน

ในบทช่วยสอนนี้ เรียนรู้วิธีการ:

  1. รับรองความถูกต้องโดยใช้ Power Platform API
  2. สร้างรายงาน
  3. รายการรายงานทั้งหมดสำหรับผู้เช่า
  4. ดึงรายงานเดียว

สำคัญ

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการแยกผู้เช่า โปรดดู ข้อจำกัดขาเข้าและขาออกระหว่างผู้เช่า

ขั้นตอนที่ 1 ตรวจสอบความถูกต้องโดยใช้ Power Platform API

ใช้สคริป PowerShell ต่อไปนี้เพื่อตรวจสอบความถูกต้องโดยใช้ Power Platform API

หมายเหตุ

ผู้ใช้ที่มีบทบาทผู้ดูแลระบบ Entra ID ใน Power Platform มีสิทธิ์เรียกใช้รายงานผลกระทบการแยกผู้เช่า

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 - รายงานการเชื่อมต่อผู้เช่าระหว่างกัน