Search for Knowledge Articles - Manage knowledge search providers
Hi,
I would like to add some standard additional search providers here for all console users to be able to see.
Trouble is, any I add are available only to me and I cannot see where SCSM stores them, does anyone know?
Cheers,
Rob
Update - they are stored in MT_System$Search$ProviderConfig, just working out how users refer to them...
-
Edited by
Rob.FordModerator
Friday, September 23, 2011 12:14 AM
September 22nd, 2011 11:57pm
September 23rd, 2011 6:15am
Hi Patrik, yes, but to how to add them once so all console users see them without having to configure them themselves?
I need to add a standard set of providers that all Analysts can use.
Cheers,
Rob
September 25th, 2011 6:07pm
Hi Rob,
Each analyst has to add their own set of providers. There are no setting for search providers out-of-box.
Thanks
Kevin
September 26th, 2011 7:58pm
Hi Rob
The System.Search.ProviderConfig class is inherited from System.UserPreference.
The System.UserPreference has a relationship with System.User.
So you can use that relationship to add your search provider to all users (or list of users).
Something like what (not tested!):
$provider = get-SCSMObject (get-SCSMClass System.Search.ProviderConfig) | ? {$_.ProviderName -eq "Google"}
$rel = Get-SCSMRelationshipClass -Name System.UserHasPreference$
get-SCSMObject -class (get-SCSMCLass -name "System.User") | % {
new-SCSMRelationshipObject $rel -Source $_ -Target $provider
}
September 26th, 2011 9:23pm
Thanks, Anton, that looks good, it didn't ocurr to me that this would be a relationship accessible from the SDK, I should have realised :)
September 28th, 2011 12:43am
And the result from Anton's advice:
class ProvidersClass
{
public bool AddProvider(
EnterpriseManagementGroup emg,
string sProviderName,
string sUrl,
EnterpriseManagementObject emoUser
)
{
try
{
//Get the Has Preference (System.SupportingItem.Library) relationship
ManagementPackRelationship relPref =
emg.EntityTypes.GetRelationshipClass(new Guid("649e37ab-bf89-8617-94f6-d4d041a05171"));
//System.Search.ProviderConfig
ManagementPackClass mpcSearchProvider = emg.EntityTypes.GetClass(new Guid("32b66b6f-1629-c411-394e-fea87a65143c"));
//Create a new relationship for the provider
CreatableEnterpriseManagementRelationshipObject cemroProvider =
new CreatableEnterpriseManagementRelationshipObject(emg, relPref);
//Create a new provider object
CreatableEnterpriseManagementObject cemoProvider =
new CreatableEnterpriseManagementObject(emg, mpcSearchProvider);
//Setup the properties
cemoProvider[mpcSearchProvider, "Id"].Value = Guid.NewGuid().ToString();
cemoProvider[mpcSearchProvider, "ProviderName"].Value = sProviderName;
cemoProvider[mpcSearchProvider, "DisplayName"].Value = sProviderName;
cemoProvider[mpcSearchProvider, "Url"].Value = sUrl;
//Create and save the relationship
cemroProvider.SetSource(emoUser);
cemroProvider.SetTarget(cemoProvider);
cemroProvider.Commit();
return true;
}
catch
{
return false;
}
}
}
-
Marked as answer by
Rob.FordModerator
Wednesday, September 28, 2011 2:48 AM
-
Edited by
Rob.FordModerator
Wednesday, September 28, 2011 2:51 AM
September 28th, 2011 2:47am
Rob, you can mark this method as static and use it directly without create new insntance:
// current implementation
ProvidersClass cl = new ProvidersClass();
bool res = cl.AddProvider(........);
// ====================================
// mark as static
public static bool AddProvider(.........)
{
..............
}
// use directly
bool res = ProvidersClass.AddProvider(..........);
September 28th, 2011 8:22am
Very true, thank you :)
October 3rd, 2011 6:22pm
Has their come a better solution for doing this in SCSM 2012R2.
Is this VB or Powershell script and where is the script executed?
April 24th, 2015 7:23am