0

I was trying to connect to SharePoint online via Connect-SPOService where I do not have a username/password and have only clientId and clientSecret. While surfing online I get https://sharepoint.stackexchange.com/questions/258597/connect-sposervice-using-app-id-and-app-secret this link and it says you can do Connect-SPOService equivalent via Connect-PnPOnline. I have tried to connect Connect-PnPOnline like

Connect-PnPOnline -Url https://org-admin.sharepoint.com -ClientId 7b2cd291-87e9-49fc-888e-xxxxxxxxxxxx -ClientSecret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

And I can successfully connect. But I need Get-SPOTenant and Get-SPOTenantSyncClientRestriction details via Connect-PnPOnline or Microsoft graph API. I am new to the Microsoft ecosystem and not sure how to get it.

user2250152
  • 14,658
  • 4
  • 33
  • 57
Divyesh Jesadiya
  • 1,105
  • 4
  • 30
  • 68

1 Answers1

0

There are equivalent commands available in PnP PowerShell for the commands you are looking for.

Check these alternative commands:

  1. For Get-SPOTenant: Use Get-PnPTenant

  2. For Get-SPOTenantSyncClientRestriction: Use Get-PnPTenantSyncClientRestriction

Update from comments:

Use PnP PowerShell commands like this:

// Connect to SharePoint Online
Connect-PnPOnline -Url https://org-admin.sharepoint.com -ClientId 7b2cd291-87e9-49fc-888e-xxxxxxxxxxxx -ClientSecret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

// Get tenant details
Get-PnPTenant

You can also specify the tenant admin URL with Connect-PnPOnline command using -TenantAdminUrl parameter. Check documentation of Connect-PnPOnline for more information: Connect-PnPOnline

Ganesh Sanap
  • 1,386
  • 1
  • 8
  • 18
  • I am geting "Get-PnPTenant : Cannot contact site at the specified URL https://org-admin.sharepoint.com/. The app principal does not exist." error while running Get-SPOTenant command. – Divyesh Jesadiya Jun 13 '23 at 13:44
  • check updated answer. – Ganesh Sanap Jun 13 '23 at 13:57
  • I was doing the same way as your updated answer but was unsuccessful. what would be TenantAdminUrl here? – Divyesh Jesadiya Jun 13 '23 at 14:28
  • You can go to SP admin center using URL: https://go.microsoft.com/fwlink/?linkid=2185219. Once you login, anything before `/_layouts/` in browser URL is your tenant admin URL. Generally, it is in same format as you are using like: `https://contoso-admin.sharepoint.com/`. – Ganesh Sanap Jun 14 '23 at 06:29