title: While creating new mysite in sharepoint set database
body: <p>Im wondering if there is a way i can tell what database i want the new mysite to be create in.</p>
  
  <p>In our server we have multiple databases for mysites <code>SP_MySiteContent00</code> and <code>SP_MySiteContent01</code> and so on. But the script below creates them all in <code>SP_MySiteContent</code> by default.</p>
  
  <p>Anyone know how can tell what database it should use?</p>
  
  <p>This is my code:</p>
  
  <pre><code>param
  (
  [Parameter(Mandatory=$true)]
  [string]$username,
  [string]$database
  )
  
  asnp *sh*
  
  
  $mysite = (Get-SPSite)[0]
  
  $context = [Microsoft.Office.Server.ServerContext]::GetContext($mysite)
  $upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
  
  #Create user profile
  $profile = $upm.ResolveProfile($username)
  
  if(!$profile)
  {
  Write-Host "$profile does not have a profile. Can't create personal site"
  }
  
  elseif($profile)
  {
      if($profile.PersonalSite -eq $Null)
      {
       $profile.CreatePersonalSite()
       Write-Host "Personal site created"
      }
      else
      {
      Write-Warning "$username already has a personal site"
      }
  }
  </code></pre>