Move SharePoint Search Index Location from C drive to other Drive
We can move search index location using Powershell in SharePoint 2010, SharePoint 2013.
Powershell Script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the current Search topology
$ssa = Get-SPEnterpriseSearchServiceApplication “Search Service Application”
$instance=Get-SPEnterpriseSearchServiceInstance -Local
$current=Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
#Clone the current Search topology
$clone=New-SPEnterpriseSearchTopology -Clone -SearchApplication $ssa -SearchTopology $current
#Servers
$hostSrch1 = Get-SPEnterpriseSearchServiceInstance -Identity “ServerName”
$hostSrch2 = Get-SPEnterpriseSearchServiceInstance -Identity “ServerName”
#Declare New Index location
$PrimaryIndexLocation = “D:\Search\IndexLocation”
$ReplicaIndexLocation = “D: \Search\IndexLocation”
#Adding new Index components
New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostSrch1 -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostSrch2 -RootDirectory $ReplicaIndexLocation -IndexPartition 0
#Deleting of old Index components
$comp1=Get-SPEnterpriseSearchComponent -SearchTopology $clone | ? {$_.Name -eq “IndexComponent1”}
$comp2=Get-SPEnterpriseSearchComponent -SearchTopology $clone | ? {$_.Name -eq “IndexComponent2”}
Remove-SPEnterpriseSearchComponent -Identity $comp1 -SearchTopology $clone
Remove-SPEnterpriseSearchComponent -Identity $comp2 -SearchTopology $clone
#Activate the cloned Search topology
Set-SPEnterpriseSearchTopology -Identity $clone
#Remove the old Search topology
Remove-SPEnterpriseSearchTopology -Identity $current
#Remove the old index component
This must be done by get, clone, modify, activate the new search topology and remove the old search topology.
$current=Get-SPEnterpriseSearchTopology -SearchApplication $ssa
$clone=New-SPEnterpriseSearchTopology -Clone -SearchApplication $ssa -SearchTopology $current
#Activate the cloned Search topology
Set-SPEnterpriseSearchTopology -Identity $clone
#Remove the old Search topology
Remove-SPEnterpriseSearchTopology -Identity $current
OR
#Retrieve the inactie Topologies
Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchTopology |? {$_.State -eq “Inactive”}
#Remove the inactive Topologies
Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchTopology |? {$_.State -eq “Inactive”} |% { Remove-SPEnterpriseSearchTopology -Identity $_ -Confirm:$false};