Forum Discussion
Mel_C13
Jul 30, 2024Brass Contributor
How to find out the weight context of all Managed Properties
Hi there I have a situation where I need to get the Context weight group of each managed property in our SPO tenant. I was hoping there was a way to get this with a Powershell script or some sort ...
Mel_C13
Aug 01, 2024Brass Contributor
michalkornet I have been able to change the Context in the Managed Properties area of the SharePoint Search Admin area. But where I am stuck is that I have over 4000 managed properties and I want to see which ones aren't Context 0 without having to go into each property.
I am hoping there is some sort of script that I can run to grab that info.
michalkornet
Aug 03, 2024Iron Contributor
Hi Mel_C13, I tested it once again on my tenant, and I am able to get this value by calling the page (
`https://${tenantName}-admin.sharepoint.com/_layouts/15/searchadmin/ta_managedproperty.aspx?property=${property}&level=tenant` )
and then extracting it from the HTML. I think this is not the best solution, but it looks like it works.
The result looks like this ->
The code that should be executed on the admin site:
(async () => {
const tenantName = 'Your tenant'
const managedPropertyName = ['AADObjectID', 'AccountName'];
for (let property of managedPropertyName) {
const web = await fetch(`https://${tenantName}-admin.sharepoint.com/_layouts/15/searchadmin/ta_managedproperty.aspx?property=${property}&level=tenant`)
const htmlResult = await web.text();
const tempContainer = document.createElement('div');
tempContainer.innerHTML = htmlResult;
const inputElement = tempContainer.querySelector('#ctl00_ctl00_PlaceHolderContentArea_PlaceHolderMain_weightGroupHiddenTextBox');
const weightGroupValue = inputElement['value'];
console.log(`Managed Property: ${property} - WeightGroupValue ${weightGroupValue}`)
}
})().catch(console.log)
Let me know if it works for you. To be honest, I still cannot edit these values on my tenant, so I hope the script does not return the default values for these properties.