Is there a way to assign a SharePoint Foundation search server to a content database using PowerShell, either while creating an Sp-WebApplication using New-SpWebApplication or by updating an SpWebApplication?
It's not possible to set this property at the web application level per se, as it is a per-database property. However, it is quite easy to set this property on a per-database level for an entire web application (With the only difference being that all new databases will not automatically have this setting).
To do this, you first need to find a database that has this search server already set. For example:
Where "CorrectDatabaseName" is the name of the database that has this property already set.
What you now need to do is iterate over all databases in the destination web application, and set the SearchServiceInstance property to be the same as the correct DB. You can do this like this:
where "WebAppNameOrUrl" is either the friendly name or the URL of the web application you wish to apply this property to. Alternatively, you could create your SPServiceInstance object another way, but i've found this to be the easiest way by far.
You can double-check to ensure that this property has been set on all the content databases by using the following:
A way to update all content databases.