Apply C# code in Power Shell
# ----------- Csharp code for variations -------------- $Assem = ( "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" , "Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" , "Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" , "Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" , "Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ) $Source = @" using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Administration; using System.Threading; using Microsoft.Office.Server; using Microsoft.Office.Server.Search.Administration; using Microsoft.Office.Server.Search.Query; namespace CustomCode { public static class GPSearchScopeGroup { public static void UpdateGPSearchScopeGroup(string weburl) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(weburl)) { using (SPWeb _web = site.RootWeb) { /// Your Code will go here..... } } }); } } } "@ write-host "Loading Scripts" Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharpVersion3 -ErrorAction Stop write-host "Call Methods of C# code"-foregroundcolor green [CustomCode.GPSearchScopeGroup]::UpdateGPSearchScopeGroup($siteURL)
Write-Host "Finished Updating Search Dropdown and set Search To Default" -foregroundcolor green
Comments
Post a Comment