Sorry for the delay in posts recently, between work and personal events I have been totally swamped (in a good way)!
What I wanted to share today is PowerShell script which provisions result sources at the Site Collection level. The script will loop through each result source within the script, check to see if it exists, if it does it will blow it away and re-create it or if it is brand new just create This script is useful for automating deployments or if you need to create the same result sources on multiple site collections.
If you need to deploy result sources at the Search Service Application Level, simply swap out: SPSite with Ssa at our $searchOwner line. Your site collection URL and Search Service Application are both params which will be prompted.
The real question though, what do you need to update in order to use this script? Luckily, the only parts you need to update are the actual result sources themselves! This is under the Result Sources Start Here Section. The below example is for a result source which finds anything with the ContentTypeId matching Article. For the below section I did not need a sort order, but if you do un-comment out the sortCollection and queryProperties line. You can swap out "Created" with the Managed property you need to sort by. You can also swap out Descending with Ascending if desired. The name of the result source is input between the single quotes, my example result source below will be called Articles.
Well that is really it folks, hopefully this helps to automate some deployments or at the very least was an interesting read!