Tạo trang web của tôi cho tất cả người dùng trong SharePoint bằng PowerShell
SharePoint My Sites được tạo tự động khi người dùng nhấp vào liên kết Nội dung của tôi trong menu chào mừng lần đầu tiên. Tuy nhiên, để thúc đẩy việc sử dụng mạng xã hội SharePoint, chúng tôi đã quyết định tạo trước các trang SharePoint của tôi cho tất cả người dùng.
Tạo trang web của tôi cho tất cả người dùng trong SharePoint bằng PowerShell
Đây là cách tạo “Trang web của tôi” cho người dùng SharePoint (Nếu nó chưa được tạo!):
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function Create-MySite($MySiteHost, $UserAccount)
{
#Get Objects
$ServiceContext = Get-SPServiceContext -site $MySiteHost
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
#Check if user Exists
if ($UserProfileManager.UserExists($UserAccount))
{
#Get the User Profile
$UserProfile = $UserProfileManager.GetUserProfile($UserAccount)
#Check if User's My site is Cretaed already
if($UserProfile.PersonalSite -eq $Null)
{
$UserProfile.CreatePersonalSite()
write-host "My Site Created Successfully for the User!" -f Green
}
}
else
{
write-host "$($UserAccount) Not Found!" -f Red
}
}
Create-MySite "https://mysite.crescent.com" "Crescent\Salaudeen"
SharePoint: Tạo trang web của tôi cho tất cả người dùng sử dụng PowerShell:
Với tư cách là quản trị viên SharePoint, bạn muốn đảm bảo rằng Site của tôi được cung cấp cho tất cả người dùng trong tổ chức. Trong hướng dẫn này, chúng tôi sẽ chỉ cho bạn cách sử dụng PowerShell để tạo trước Trang của tôi cho mọi người.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$MySiteHost = "https://mysite.crescent.com"
#Get Objects
$ServiceContext = Get-SPServiceContext -site $MySiteHost
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
#Get All User Profiles
$UserProfiles = $UserProfileManager.GetEnumerator()
#Iterate through each profile
foreach ($Profile in $UserProfiles)
{
if($Profile.PersonalSite -eq $Null)
{
#Check if User's My site is Cretaed already
if($Profile.PersonalSite -eq $Null)
{
#$UserProfile.CreatePersonalSite()
write-host "My Site Created Successfully for the User:" $Profile["AccountName"] -f Green
}
else
{
write-host "My Site Already Exists for the User:" $Profile["AccountName"] -f Red
}
}
}
BTW, tôi đã thử nghiệm tập lệnh này trong SharePoint 2013 để tạo trang web của mình cho tất cả người dùng!
