Because Clicking Around in Search Admin Is Not a Strategy: Microsoft Search Cmdlets Landed in PnP PowerShell

002dc20a-5bf3-4234-aafe-0c41e37f4a8b

I had this pull request merged back in February and then... forgot to blog about it. Better late than never. Here you go!Z

PR: https://github.com/pnp/powershell/pull/5242

If you’ve ever tried to automate Microsoft Search verticals and result types and ended up rage-clicking in admin UIs instead, this one is for you.

What was added

This PR adds cmdlets for managing Microsoft Search configuration through PnP PowerShell:

Search verticals

  • Get-PnPSearchVertical
  • New-PnPSearchVertical
  • Set-PnPSearchVertical
  • Remove-PnPSearchVertical
  • Set-PnPSearchVerticalOrder

Search result types

  • Get-PnPSearchResultType
  • New-PnPSearchResultType
  • Set-PnPSearchResultType
  • Remove-PnPSearchResultType
  • New-PnPSearchResultTypeRule

Site connections

  • Get-PnPSearchSiteConnection

In short: proper scripting support for verticals/result types/site connections, instead of “hope-and-click” operations in multiple portals.

Important caveat (read this)

These cmdlets use the Graph Connector Service (GCS) API endpoint used by the same Microsoft admin experiences, but it is not publicly documented/supported.
So yes, it works. Also yes, the API can change whenever it wants to. All work done using reverse engineering of the admin UX experience.

You need delegated permission from the GCS app registration (not the standard Graph one) – no app only as the API was build for the admin UX:

  • API app id: 56c1da01-2129-48f7-9355-af6d59d42766
  • Scope: ExternalConnection.ReadWrite.All (d44774bd-e26c-43b1-996d-51bb90a9078e)

Which PnP PowerShell version has this?

  • First stable release: v3.2.0
  • First nightly containing it: 3.1.311-nightly

So if you’re looking for this in older stable versions, that’s why you’re not seeing it.

Quick start

Install-Module PnP.PowerShell -RequiredVersion 3.2.0 -Scope CurrentUser
# or update if already installed
Update-Module PnP.PowerShell