Here is essentially what I tried:
$URL = "http://someurl"
$accountName = "myuser"
$site = New-Object Microsoft.SharePoint.SPSite($URL)
$context = [Microsoft.Office.Server.ServerContext]::GetContext($site)
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userprofile = $upm.GetUserProfile($accountName)
This was not successful in creating the personal site.
The account under which I run this has administrator rights on the User Profile Service Application, and is in the Farm Administrators Group. In the ULS there was an entry for "Access Denied". I also do have Self Service Site Creation enabled.
Seeing as this was an "Access Denied" I then tried to run the script as the SharePoint Farm Account. This was successful. Unfortunately, I do not want to run this script as the Farm Account.
Next step was to try running this with elevated privileges which involved putting my code within this:
Still no luck
Next was to try using a different user token like this:
$site = New-Object Microsoft.SharePoint.SPSite("myurl", [Microsoft.SharePoint.SPUserToken]::SystemAccount)
or even with the user account for which I am creating the personal site.
Still no luck.
At this point, I gave up and put my script into the Task Scheduler to be executed as the Farm Account.
It would be nice to know exactly what permission is missing.