Came across a useful script for an age old problem in SharePoint. May work on versions beyond 2013, but haven’t tested. Posting here for future reference (Found here: https://ehikioya.com/sharepoint-access-requests-powershell/):
In an effort to setup Enterprise Search in SharePoint 2013 using PowerShell to make sure every nook and cranny was covered, I came across a number of scripts, but none seemed to do as good of a job as this one. I’m not sure what the original source is or who put it together, but it worked flawlessly. This is probably by far the best PowerShell script I have found for setting up Enterprise Search that does a good job of setting up every component. Enjoy!
Before running, create a folder on a hard drive of your choosing where indexes will be stored. In this case, I used “C:\SPSearchIndexes” for the Index location. This has to be created beforehand, otherwise it will fail!
If you’re ever in need of converting your existing web applications within SharePoint to claims authentication from classic auth, you’ll need to run the following commands.
In order to do this, you’ll need to use the SharePoint PowerShell command prompt and run the commands in the order below under your farm service account:
Need to give a service account access to a web application in SharePoint 2013? Easy! Just run these two PowerShell commands as the farm service account in the SharePoint PowerShell command prompt:
$webApp = Get-SPWebApplication http://contoso.com $webApp.GrantAccessToProcessIdentity("CONTOSO\svcacct-contoso")
In SharePoint 2010, if you had other domains that you needed to lookup users on in order to give them access to a site, it just worked without having to do any further configuration.
Not so with SharePoint 2013. You must add each domain and sub-domain to each web application to be able to perform user lookups from within the people picker.
So how do you do this? Well, with PowerShell, and fortunately Microsoft has provided a nice script that performs it for you. Otherwise, it would be quite a task.
It’s important to note that you must add the default domain your SharePoint environment is currently setup in. Otherwise, you won’t even be able to do lookups in it! (Found that out the hard way)
Instructions: Open Notepad or your favorite text editor, copy and paste the code below into the file, and save it as a .ps1 file. Open the SharePoint PowerShell command window as an Administrator, and an account with farm level access, change the directory (cd C:\YourDirectory, etc.) to the place you saved the code below (as a .ps1 file), type out .\YourPowerShellScript.ps1 and hit enter.
*I provide this as is, with no guarantees it will resolve your issues. And if you muck up your environment, it’s not my fault. 🙂 Obviously you should perform this on a dev or test environment first before attempting it in production. Good luck!*
Since I had to piece together how to accomplish the migration of a host-named site collection (HNSC) I had already setup in SharePoint 2013, from one farm to another, I figured I would outline exactly how to do it. In my case, I needed the HNSC to be in its own content database, I’m targeting a particular web app with the HNSC as opposed to using a wildcard web app to handle the hostnames, and all of this is assuming you have your rights setup to be able to carry out all of this; SQL, SharePoint farm account and otherwise. With that said…