Collaboration-2-Go


Lösungen und Software-Entwicklung im Collaboration Umfeld, insbesondere Microsoft SharePoint, Microsoft Exchange und Microsoft Office.

Support


Mobil: +49 (152) 53 97 78 79
Mail: service@collaboration-2-go.de
Weitere Kontaktmöglichkeiten: Kontaktseite
Dekoration: Köln



Create SharePoint 2013 MySites
Created: 10.01.2014
Categories: SharePoint 2013; SharePoint Development; PowerShell

Create SP2013 MySites using an AD group and PowerShell:

$adGroup = ""  # AD Group with MySite users
$siteURL = ""  # any local SharePoint Site will do

$members = Get-ADGroupMember -Identity $adgroup -Recursive | sort name

# get UserProfileManager
$serviceContext  = Get-SPServiceContext -site $siteURL -ErrorAction Stop
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext) -ErrorAction Stop

foreach ($member in $members)
{
if ($upm.UserExists($member.SamAccountName))
{
  $profile = $upm.GetUserProfile($member.SamAccountName)
  $perssite = $profile.PersonalSite

  if ($perssite -eq $null)
  {
    # either this
    $profile.CreatePersonalSite(1031)  # should work in most cases
    # or this
    # $profile.CreatePersonalSiteEnque($true)  # will work in all cases; gets language from mysite host

    $perssite = $profile.PersonalSite
    if ($perssite -eq $null)
    {
      # do some error handling
    }
  }
}
}

    

Send us a Comment!