Monday, 1 August 2011

Enable search on an External Content Type in SharePoint 2010 using PowerShell

When you create a custom BDC External Content Type (or “Entity”) for use in SharePoint 2010 and deploy it in the Business Data Connectivity Service Application, it will not be “crawlable” from the SharePoint search application by default.

There is a great article from Chaks here on the detail, so I do not see any need to repeat the article he has written. However, one approach that may be preferable when configuring the entity and Lob System Instance could be to use PowerShell instead.

In my example, I have created a very simple External Content Type (ECT) to show a people table from a SQL database. As you can see from the screenshot below, the option to crawl the ECT is set to “No”:

image

To retrieve the ECT for configuration in PowerShell, you can use the Get-SPBusinessDataCatalogMetadataObject cmdlet provided with SharePoint 2010. The script below will retrieve the “People” ECT shown above:

$entity = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Entity" -Name "People" -Namespace "http://portal.pacdomain.local" –ServiceContext “http://centraladminURL:port

Next, the following lines of script retrieve the “ReadList” method instance, as suggested in Chaks article:

$methodinstance = $entity.MethodInstances | where {$_.Name -eq "ReadList"}

It is here that we need to add the “RootFinder” property. If you wish to view a list of the current properties set on the method instance, simply type $methodinstance.Properties. To add a new property, type the following command:

$methodinstance.Properties.Add("RootFinder", "")

You may also wish to switch on the optional “UseClientCachingForSearch” property, which can speed up the crawls to the ECT, but ensure that you read this article first before doing so as there are some caveats to think about:

$methodinstance.Properties.Add("UseClientCachingForSearch", "")

Once you have finished making these changes, update the method instance as follows:

$methodinstance.Update()

The ECT will now show as “Crawlable”:

image

Note, that you can also use the “Remove” method to delete any property set on the method instance. This could be used to remove the search option on an ECT – even those created in SharePoint Designer, where the “crawlable” option is switched on by default. For example, type the following to remove the “UseClientCachingForSearch” property:

$methodinstance.Properties.Remove("UseClientCachingForSearch")
$methodinstance.Update()

Next, we need to switch on the “ShowInSearchUI” property for the Lob System Instance. This allows the BDC model instance to be seen in the SharePoint search administration interface when creating a content source to crawl business data. At this point you will need to know the name of the Lob System Instance for this ECT – if you’re not sure what this is, type $entity.LobSystem.LobSystemInstances to find it. In this example, the name is “Test Database”:

image

We can now use this name to get the Lob System Instance, configure the ShowInSearchUI property, and update the item:

$lobSI = $entity.LobSystem.LobSystemInstances | where {$_.Name -eq "Test Database"}
$lobSI.Properties.Add("ShowInSearchUI", "")
$lobSI.Update()

Again, the property can be removed using the “Remove” method as before, should you wish to hide a Lob System Instance from the search administration interface again.

27 comments:

  1. Thank you !!! for sharing above power shell code pointers...it was very useful for me ..

    ReplyDelete
  2. That's a great post, works like a charm :)

    ReplyDelete
  3. Model Karrueche Tran is in the headlines a lot at the moment. She’s controversial rapper Chris Brown’s ex for one thing. And of course now that Brown and Rihanna are back together there’s rbodm much speculation on the nature of Brown’s continued friendship with the model.Today, though we’re more interested in those stylish Dior Homme sunglasses. Karrueche spotted here out and about ray ban store in L.A soon after her split with Ray Ban Sale Brown, showed her style mettle with a really neat choice of designer sunglasses to hide that very public gaze.Karrueche chose the Dior Homme Black Tie in havana as she hit the streets of L.A. The Black Tie is a modern aviator with a distinctive brow that really accentuates the eyeline.It’s ray bans on sale a perfect moving on accessory for Karrueche who is now said to be getting close to Brown’s friend, Kendrick Lamar. So more headlines to follow then...
    Jessica Chastain ray ban wayfarer is a very happy lady it would seem. The quiet star is flourishing in a new romance with a tall dark Italian, and was the first female actress ray ban aviators in 50 years to have a leading role in hit movies at the same time with Mama and Zero Dark Thirty.There’s last year's Time 100 most influential people listing ray ban one day sale 90% off too. So what do the world’s best wear on their eyes? One of designer eyewear’s best – Persol sunglasses.Persol 3015 is a striking frame and perfect for cheap ray ban sunglasses sale under 30$ this strikingly beautiful actress. The retro shape is so typical of the 50s silver screen heyday, while as a pair of sunglasses the Persol 3015 comes with that ray ban clubmaster ‘Made in Italy’ stamp that exudes quality craftsmanship.Recently spotted at Paris Fashion Week , Chastain was snapped admiring her new man Gian Luca Passi de Preposulo. Jessica Chastain cheap ray bans is known for her incredible style and Preposulo is an executive at French fashion house Moncler.So it’s not just Jessica’s Persol sunglasses that have a ‘Made in Italy’ designer cheap ray bans for sale

    ReplyDelete
  4. The blog or and best that is extremely useful to keep I can share the ideas of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    animal jam | five nights at freddy's | hotmail login

    ReplyDelete

  5. الان مع افضل ما توصل له علم الديكورات الحديث من تصميمات نقدم لكم جماليات ورق جدران ثلاثى الابعاد بطلائاتها الجديدة لمنتجات ورق جدران ثلاثي الابعاد فى الرياض فالان ان كنت بمرحلة الانشاء لمنزلك وترغب فى تصميم افضل الديكورات بمنزلك واختيار افضل دهانات الحوائط او ورق حائط ثلاثي الابعاد و ورق الجدران لغرف النوم وايضا دهانات دكتور بينت فكل انواع الدهانات الحديثة نقدمها لكم عملائنا الكرام .

    نحن نقدم كل جديد فى عالم الديكورات ونوفر لكم ورق جدران للمطبخ وللصالات بافضل استايل وخاص فقط بنا وبجودة عالية جدا ولكل من يبحث عن الرقى والجودة فنحن نقدمها لك باقل الاسعار وبافضل الخامات للارضيات والحوائط وكافة اعمال الديكورات ونقدم لعملائنا التى تم التعامل معهم افضل انواع الديكورات مثل ورق الجدران ثلاثى الابعاد بالرياض وبجدة وبالدمام الذي يجعل منزلك قطعة من لوحة فنية .

    ReplyDelete
  6. At putting forward your primary quote, You are investing buy this fact product from owner if you're succeeding prospective buyer. You read and conform to the worldwide delivery approach agreements starts up in model new pane otherwise case. Scan expenses witout a doubt estimated will definitely be be more responsive to change inside raise you limit say cash..

    (7) Fr Vorkasse Bestellungen gilt eine Zahlungsfrist juegos de futbol von einer Woche belly Zugang der Vertragsbesttigung. Der Anbieter legt kick the bucket gewnschte Ware whrend der Dauer der Zahlungsfrist fr home Kufer zurck. Es obliegt dem Kufer, Seine Zahlung so, rechtzeitig zu bewirken, Dass dfb trikot müller sie beim Zahlungsempfnger innerhalb der Frist resultados de futbol eingeht. maillot de foot pas cher

    Get more goes into business in a unique time frame or tabInternational postage and packing and Maillot De Foot Pas Cher / or scan accusations fee-based so that you Pitney Bowes corporation. Here is calendario de futbol additional information starts in Maglie Calcio Poco Prezzo a whole new windows or tabAny overseas distribution since transfer allegations were gave just if you want to camisetas de futbol baratas actually Pitney Bowes corporation. Find out more starts up in a amazon müller trikot fresh screen or tabInternational postage and hummel trikots packing give to assist you for Pitney Bowes corporation.

    ReplyDelete
  7. They hope underrated Ashton Saunter can build on his late season, five game NHL audition. click here They hope there optimism with the undrafted Jalen Chatfield in the top playoff pairing for the Utica Comets. And they hope 2015 third rounder Guillaume Brisebois is better than a third pairing AHL defender.

    That a lot of hope.

    has been my experience that if you go for position, you make mistakes, said Benning. want to take the best available when you pick and that will be our strategy. Positional needs? We can find other ways to find those type of players. the Canucks select Coach factory outlet website sixth through eighth, there could be four blue liners who address skill and positional concerns. The elite in this draft Dahlin and wingers Andrei Svechnikov, Brady Tkachuk and Filip Zadina are locks in the top four. But it gets interesting after coach factory online sale that. He convinced the Canucks can land a defenceman no matter where they pick because four are ranked from fifth to 12th.

    Evan Bouchard, Adam Boqvist, Noah Dobson and Quinn Hughes could all fall to the Canucks especially if they stay in the No. 6 slot while centre Oliver Wahlstrom is worth a look if there are top five reaches for D men.

    Here are five the Canucks could consider with their first draft pick on June 22 in Dallas:

    EVAN BOUCHARD (D, London, OHL)

    Vitals: 6 2, 193 lbs.; GP: 67, G: 25, A: 62, Pts. 84

    Scout says: more consistent than Boqvist, particularly in defensive habits and awareness. (Coach) Dale Hunter is demanding and doesn care how good coach factory outlet online login you are offensively that a bonus he wants his defencemen to play properly. You not going to survive Coach Outlet Online Store in the NHL as a top three defenceman without being consistent. BOQVIST (D, Brynas IF, Sweden, J20)

    Vitals: 5 11, 170 lbs.; GP: 25, G: 14, A: 10, Pts. 24

    Scout says: skate out of problems and retrieve pucks quickly and turn and make an excellent first coach factory store online pass that can disrupt forecheck. Concern is his defensive awareness and habits. Inconsistent with gap control, taking right angles, keeping head on official coach factory outlet online swivel, having active stick and keeping his feet coach outlet sale moving. DOBSON(D, Acadie Bathurst, QMHL)

    Vitals: 6 3, 180 lbs.; GP: 67, G: 17, A: 52, Pts: 69

    Scout says: me of (Colton) Parayko of the Blues without the massive slapshot. He has the best percentage to be a No. 3 D man in the NHL, but also has the potential for a No. 2 because of his upside. HUGHES(D, University of Michigan, NCAA).

    ReplyDelete