This script deploys SharePoint 2013 Enterprise Search to a small, traditional, three-server SharePoint 2013 farm (1 App, 2 WFE, 1 OWA and 1 SQL), and configures it with the following application topology:
Server Role . Search Components
Application Admin, Crawler, Content Processing, Analytics Processing
WFEs Query Processing, index Partition
To use the script below, replace bracketed values with those appropriate to your own farm.
This script is based upon that originally published by Ryan Bushnell in his 7 August 2013 blog post, SharePoint 2013 Search Configuration PowerShell Script. I've made minor tweeks to his original script in order to extend it to a three-server (1 App and 2 WFE) physical topology. This script can straightforwardly be extended to larger topologies. Many thanks to Ryan for making search deployment much more automated and consistent.