Steps Involved:

1. Create the input xml file which contains the inputs for creating All Content Scope Rule.

2. Create ps1 file which contains the script for creating All Content Scope Rule.

CreateAllContentScopeRule.xml

<?xml version="1.0" encoding="utf-8" ?>

<CreateAllContentScopeRule>

<ServiceAppName>Search Service Application</ServiceAppName>

<ScopeName>All Scopes</ScopeName>

<Uri>https://serverName</Uri>

</CreateAllContentScopeRule>

CreateAllContentScopeRule.ps1

## -------------------------------------------------------------------

## Master Powershell script for creating All Content scope rule

## Note:- Need to update the XML file path before running the script.

## Author :

## Date : 31-Oct-2011

## -------------------------------------------------------------------

#----------------Get the xml file---------------------------------------------------------------

[xml]$xmlData=Get-Content "D:\VijaiPOC\CreateAllContentScopeRule.xml"

$serviceAppName=$xmlData.CreateAllContentScopeRule.ServiceAppName

$scopeName=$xmlData.CreateAllContentScopeRule.ScopeName

$uri=$CreateAllContentScopeRule.URI

#----------------Create All Content Scope Rule----------------------------------------------------

Function CreateAllContentScopeRule()

{

$ssa = Get-SPEnterpriseSearchServiceApplication -Identity $serviceAppName

$scope = Get-SPEnterpriseSearchQueryScope -Identity $scopeName -SearchApplication $ssa

$scope.Name

$sr = New-SPEnterpriseSearchQueryScopeRule -Scope $scope -RuleType AllContent -Url $uri

}

#----------------Calling the function------------------------------------------------------------

CreateAllContentScopeRule

Run the Script:

1. Go to Start.

2. Click on All Programs.

3. Click on Microsoft SharePoint 2010 Products and then click on SharePoint 2010 Management Shell (run as Administrator).

4. Run the D:\Vijai\POCScripts\CreateAllContentScopeRule.ps1