4

I am trying to use a service principal I have created in AzureAD to connect via a PowerShell script. I created the SP successfully, created the key, and also created a self signed cert and associated it with the account. I know how to use Connect-AzureAD but Connect-MSOLservice doesn't seem to allow me to enter the values needed.

I have tried using the standard connection string as you would with Connect-AzureAD but it doesn't seem to take the same input.

Connect-MsolService -TenantId "xxxx" -ApplicationId "xxxx" -CertificateThumbprint "xxxx"

I'm hoping someone can show me or point me in the direction of how to use the Connect-MSOLservice command using either the key or cert associated with the Service Principal.

Dexter
  • 2,482
  • 27
  • 40
CptSternn
  • 41
  • 1
  • 6

1 Answers1

0

It's not possible to use service principal to Connect AAD via "Connect-MSOLservice"

Why:

Actually, MSOL Powershell is Office 365 Powershell. It's designed for managing O365 online services. Therefore, it could only be logged in via Office 365 users.

Hence, you cannot use Connect-MsolService with Guest users and service principals because they're not O365 users.

Wayne Yang
  • 9,016
  • 2
  • 20
  • 40
  • 2
    That makes sense but how are we supposed to automate Powershell scripts that use MSOL services to run as Scheduled Tasks in environments with MFA enabled? – CptSternn Apr 23 '19 at 08:27
  • I can find examples with how to use a partnercenter CSP connection.. can you just do this against an Azure AD/O365 tenant directly? – Paul O'Brien Jun 12 '20 at 02:16