Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
nbs33
Helper II
Helper II

Error Authenticating as Service Principal using PowerShell Script

I am trying to write some scripts to manage out PBI for an embed project. I am using the PS script below that I found online.  I am going this "Cannot bind argument to parameter 'Credential' because it is null" error.

 

I verified the Secret, Tenat ID and App ID are correct. I'm stumpped because there is clearly a value for the Client Secret so I am not sure why it is 'null'. 

 

I am new to PS so I'm hoping there is an obvious error. Any help is greatly appreciated.

 

 

Error:

 

Connect-PowerBIServiceAccount : Cannot bind argument to parameter 'Credential' because it is null.
At C:\Users\micha\OneDrive\Documents\_NBS_Solutions\_Customers\AgencyKPI\Powershell\Test Scripts\Report Distrobution Script.ps1:16 char:81
+ ...  -ServicePrincipal -TenantId $TenantId -Credential $PbiCredentialName
+                                                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Connect-PowerBIServiceAccount], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount

 

 

Script:

 

#Variables 
$AppId = "*************"
$TenantId = "*************"
$ClientSecret = "*************"

#Create secure string & credential for application id and client secret
$PbiSecurePassword = ConvertTo-SecureString $ClientSecret -Force  -AsPlainText 
$PbiCredential = New-Object Management.Automation.PSCredential($AppId, $PbiSecurePassword)


#Connect to the Power BI service
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredentialName

 

  

 

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @nbs33 ,

 

To learn how to create a service principal for use with Azure PowerShell, see Create an Azure service principal with Azure PowerShell.

 

To sign in with a service principal, use the ServicePrincipal parameter of the Connect-AzAccount cmdlet. You'll also need the service principal's application ID, sign-in credentials, and the tenant ID associate with the service principal. How you sign in with a service principal depends on whether it's configured for password-based or certificate-based authentication.

 

For reference:

Password-based authentication

Certificate-based authentication

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @nbs33 ,

 

To learn how to create a service principal for use with Azure PowerShell, see Create an Azure service principal with Azure PowerShell.

 

To sign in with a service principal, use the ServicePrincipal parameter of the Connect-AzAccount cmdlet. You'll also need the service principal's application ID, sign-in credentials, and the tenant ID associate with the service principal. How you sign in with a service principal depends on whether it's configured for password-based or certificate-based authentication.

 

For reference:

Password-based authentication

Certificate-based authentication

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.