共用方式為


Connect-DataGatewayServiceAccount

連線到資料閘道服務。

Syntax

Connect-DataGatewayServiceAccount
       [-Environment <PowerBIEnvironmentType>]
       [<CommonParameters>]
Connect-DataGatewayServiceAccount
       -ApplicationId <String>
       -ClientSecret <SecureString>
       [-Tenant <String>]
       [-Environment <PowerBIEnvironmentType>]
       [<CommonParameters>]
Connect-DataGatewayServiceAccount
       -ApplicationId <String>
       -CertificateThumbprint <String>
       [-Tenant <String>]
       [-Environment <PowerBIEnvironmentType>]
       [<CommonParameters>]

Description

使用使用者或服務主體帳戶連線到資料閘道服務, (應用程式秘密或憑證) 。

針對使用者帳戶,會利用 Azure Active Directory (AAD) First-Party 應用程式進行驗證。

遵循「建立 Azure AD 應用程式」來建立服務主體帳戶。

若要登出,請登出 Disconnect-DataGatewayServiceAccount。

範例

建立 Azure AD 應用程式

若要建立與 DataGateway* Cmdlet 相容的 Azure AD 應用程式,請執行下列使用模組的 Microsoft.Graph 腳本

# In the Azure portal these will show as the Permission names "Tenant.Read.All" and "Tenant.ReadWrite.All" with the "Application" type under the Power BI Service API
$resourceAccessItems = @(
                        @{Id="654b31ae-d941-4e22-8798-7add8fdf049f";Type="Role"},
                        @{Id="28379fa9-8596-4fd9-869e-cb60a93b5d84";Type="Role"}
                        );
# In the Azure portal the ResourceAppId below is the Power BI Service
$resourceAccess = @{ResourceAppId="00000009-0000-0000-c000-000000000000"; ResourceAccess=$resourceAccessItems};

# Create the application, if you do not want the application to have full permissions remove the -RequiredResourceAccess argument
$newApp = New-MgApplication -DisplayName "DataGatewayApplication" -RequiredResourceAccess $resourceAccess

# Optionally, create a secret for the new application
$applicationPasswordRequestOptions = @{PasswordCredential=@{DisplayName="ClientSecret"}}
$applicationPasswordResponse = Add-MgApplicationPassword -ApplicationId $newApp.Id -BodyParameter $applicationPasswordRequestOptions
$clientSecret = $pwd.SecretText | ConvertTo-SecureString -AsPlainText -Force

執行上述腳本之後,還有一些完成的步驟:

  1. 如果您未使用上述腳本建立) 或使用憑證,請建立新的密碼 (。 如需詳細資訊,請參閱 憑證和秘密

  2. 如果您指定 RequiredResourceAccess 引數,請為具有已設定許可權的應用程式授與管理員同意。 如需詳細資訊,請參閱在應用程式註冊中授與管理員同意

範例 1

PS C:\> Connect-DataGatewayServiceAccount

針對公用雲端使用使用者驗證登入,系統會顯示提示以收集認證。

範例 2

PS C:\> Connect-DataGatewayServiceAccount -Environment China

使用對中國雲端的使用者驗證登入,系統會顯示一則提示以收集認證。

範例 3

PS C:\> Connect-DataGatewayServiceAccount -ApplicationId b5fde143-722c-4e8d-8113-5b33a9291468 -ClientSecret (Read-Host "Enter client secret" -AsSecureString) -Tenant 4E6F731E-FD8D-496D-8AF8-349ABC5F62E0

使用指定租使用者中針對公用雲端的服務登入,系統會顯示提示以 Read-Host 讀取用戶端應用程式密碼。

範例 4

PS C:\> ConvertFrom-SecureString -SecureString (Read-Host "Enter client secret" -AsSecureString) | Out-File -FilePath .\encryptedClientSecret.txt
PS C:\> $secureClientSecret = (cat .\encryptedClientSecret.txt | ConvertTo-SecureString)
PS C:\> Connect-DataGatewayServiceAccount -ApplicationId b5fde143-722c-4e8d-8113-5b33a9291468 -ClientSecret $secureClientSecret -Tenant 4E6F731E-FD8D-496D-8AF8-349ABC5F62E0

使用指定租使用者中的服務,使用用戶端密碼安全地儲存在檔案中的公用雲端登入,讓 Cmdlet 非互動式。

範例 5

PS C:\> Connect-DataGatewayServiceAccount -ApplicationId b5fde143-722c-4e8d-8113-5b33a9291468 -CertificateThumbprint 38DA4BED389A014E69A6E6D8AE56761E85F0DFA4 -Tenant 4E6F731E-FD8D-496D-8AF8-349ABC5F62E0

使用指定租使用者中的服務主體登入,並將已安裝憑證的憑證登入公用雲端。 憑證必須安裝在 CurrentUser 或 LocalMachine 憑證存放區中, (LocalMachine 需要安裝私密金鑰的系統管理員存取權) 。

參數

-ApplicationId

Azure Active Directory (AAD) 應用程式識別碼 (也稱為用戶端識別碼) 搭配服務主體帳戶使用。

如需應用程式和服務主體的詳細資訊,請參閱 Azure Active Directory 中的應用程式和服務主體物件

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-CertificateThumbprint

與 Azure Active Directory (AAD) 應用程式相關聯的已安裝憑證憑證指紋。 憑證必須安裝在 CurrentUser 或 LocalMachine 個人憑證存儲中, (LocalMachine 需要系統管理員提示,才能使用已安裝私密金鑰來存取) 。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ClientSecret

服務主體的應用程式用戶端密碼。

Type:SecureString
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Environment

要連線的雲端環境。 預設值為 Public。

Type:PowerBIEnvironmentType
Accepted values:Public, Germany, USGov, China, USGovHigh, USGovMil
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Tenant

包含服務主體帳戶的租使用者名稱或租使用者識別碼。 如果未指定,則會 COMMON 使用租使用者。

Type:String
Aliases:TenantId
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

None

輸出

Microsoft.DataMovement.Powershell.Abstractions.Interfaces.IPowerBIProfile