SOLVED

PnP powershell > Howto create or edit a managed property?

%3CLINGO-SUB%20id%3D%22lingo-sub-131098%22%20slang%3D%22en-US%22%3EPnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131098%22%20slang%3D%22en-US%22%3E%3CP%3EI%20try%20to%20create%20a%20provisioning%20solution%20using%20PnP%20powershell.%3C%2FP%3E%0A%3CP%3EI'm%20a%20bit%20stuck%20at%20the%20moment.%20I%20try%20to%20create%20a%20managed%20property%20(or%20edit%20the%20default%20managed%20properties%2C%20like%20RefinableString%20etc.)%20but%20I%20cannot%20find%20a%20PnP%20command%20to%20do%20that.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20commands%20should%20I%20use%20to%20achieve%20this%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%20Mike%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-131098%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-268792%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-268792%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F154002%22%20target%3D%22_blank%22%3Eravick4u%20%40hotmail.com%3C%2FA%3E%26nbsp%3BI%20think%20there%20is%20no%20cmdlet%20at%20the%20tenant%20level.%20Anyway%2C%20you%20can%20export%2Fimport%20the%20schema%20directly%20using%20the%20UI%20(Manage%20search%20schema%20in%20the%20SharePoint%20central%20admin%20portal).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-267430%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-267430%22%20slang%3D%22en-US%22%3E%3CP%3EBefore%20we%20run%20this%20command%20which%20site%20collection%20we%20need%20to%20connect.%20I%20would%20like%20to%20export%20all%20managed%20property%26nbsp%3Bwhich%20I%20have%20created%20in%20Admin%20Site.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20not%20received%20managed%20property%20when%20I%20am%20running%20this%20command%20against%20SharePoint%26nbsp%3Badmin%20sites%20as%20well%20as%20other%20sites.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131504%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131504%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20I%20remember%20correctly%2C%20SharePoint%20will%20import%20only%20changes%20from%20the%20default%20schema.%26nbsp%3BYou%20can%20verify%20easily%20this%20behavior.%26nbsp%3BI've%20used%20this%20technique%20several%20times%20with%20no%20issues%20so%20I%20suggest%20you%20to%20use%20the%20supported%20method%20rather%20than%20a%20custom%20script.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131440%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131440%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20I%20would%20like%20to%20add%20one%20managed%20property%20I%20prefer%20not%20to%20export%20and%20import%20all%20managed%20search%20settings%20but%20only%20the%20one%20that%20is%20changed.%20Or%20does%20the%20import%20some%20kind%20of%20check%3F%20If%20an%20item%20exist%2C%20than%20skip%20the%20import%20of%20the%20item%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEdit%3A%20I%20found%20this%20one%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FPowershell-script-to-250c5aa6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FPowershell-script-to-250c5aa6%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EHaven't%20test%20it%20yet%20but%20I'll%20give%20it%20a%20try%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131317%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131317%22%20slang%3D%22en-US%22%3EWhy%20you%20would%20like%20to%20do%20this%3F%20Just%20create%20your%20MP%20using%20the%20SharePoint%20UI%20and%20then%20export%20your%20schema.%20Your%20new%20MP%20will%20be%20present%20in%20your%20XML%20file%2C%20no%20need%20to%20do%20any%20additional%20configurations%20here.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131305%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131305%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019%22%20target%3D%22_blank%22%3E%40Franck%20Cornu%3C%2FA%3E%20Hmmm%2C%20that%20is%20just%20what%20I%20wanted%20to%20do%2C%20update%20the%20xml...%3C%2FP%3E%0A%3CP%3EThere%20is%20no%20way%20to%20do%20that%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131141%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20powershell%20%26gt%3B%20Howto%20create%20or%20edit%20a%20managed%20property%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131141%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Mike%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20the%20default%20SharePoint%20feature%20to%20do%20this%3A%3C%2FP%3E%0A%3CP%3E-%20Setup%20your%20search%20configuration%20via%20the%20SharePoint%20interface%20(refinable%20properties%2C%20custom%20MP%2C%20etc.)%3C%2FP%3E%0A%3CP%3E-%20Export%20as%20XML%20(via%20the%20UI%20or%20using%20the%20PnP%20cmdlet%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fblob%2Fmaster%2FDocumentation%2FGet-PnPSearchConfiguration.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGet-PnPSearchConfiguration%3C%2FA%3E)%3C%2FP%3E%0A%3CP%3E-%20Import%20your%20configuration%20via%20the%20PnP%20cmdlet%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fblob%2Fmaster%2FDocumentation%2FSet-PnPSearchConfiguration.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESet%E2%80%91PnPSearchConfiguration%3C%2FA%3E%26nbsp%3Bin%20an%20other%20site%20collection.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENote%3A%20don't%20even%20try%20to%20update%20the%20XML%20file%20by%20yourself%20%3B).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Regular Contributor

I try to create a provisioning solution using PnP powershell.

I'm a bit stuck at the moment. I try to create a managed property (or edit the default managed properties, like RefinableString etc.) but I cannot find a PnP command to do that. 

 

What commands should I use to achieve this?

 

Thanks, Mike

7 Replies

Hi Mike,

 

You can use the default SharePoint feature to do this:

- Setup your search configuration via the SharePoint interface (refinable properties, custom MP, etc.)

- Export as XML (via the UI or using the PnP cmdlet Get-PnPSearchConfiguration)

- Import your configuration via the PnP cmdlet Set‑PnPSearchConfiguration in an other site collection.

 

Note: don't even try to update the XML file by yourself ;).

 

 

@Franck Cornu Hmmm, that is just what I wanted to do, update the xml...

There is no way to do that?

Why you would like to do this? Just create your MP using the SharePoint UI and then export your schema. Your new MP will be present in your XML file, no need to do any additional configurations here.

If I would like to add one managed property I prefer not to export and import all managed search settings but only the one that is changed. Or does the import some kind of check? If an item exist, than skip the import of the item?

 

Edit: I found this one: https://gallery.technet.microsoft.com/office/Powershell-script-to-250c5aa6

Haven't test it yet but I'll give it a try

best response confirmed by Mike Jansen (Regular Contributor)
Solution

If I remember correctly, SharePoint will import only changes from the default schema. You can verify easily this behavior. I've used this technique several times with no issues so I suggest you to use the supported method rather than a custom script. 

Before we run this command which site collection we need to connect. I would like to export all managed property which I have created in Admin Site. 

 

Did not received managed property when I am running this command against SharePoint admin sites as well as other sites.

ravick4u @hotmail.com I think there is no cmdlet at the tenant level. Anyway, you can export/import the schema directly using the UI (Manage search schema in the SharePoint central admin portal).