Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
こんにちは。
SharePoint サポート チームの成田です。
今回は SharePoint Online 上の個人用サイトを管理者が予め作成する方法について記載したいと思います。
オンプレミスの SharePoint Server 2013 の個人用サイトを管理者が予め作成する方法はこちらをご確認ください。
SharePoint のソーシャル機能を使うためには、各ユーザーが個人用サイトが作成されている必要があります。
個人用サイトが作成されるタイミングは、通常はサイトページ上の [ニュース フィード] や、ユーザー名のドロップダウンの [プロファイル] をクリックした時で、クリックしてから作成が完了するまでユーザーが数分間待たされることになります。
「ユーザーがソーシャル機能を利用したいと思った時にすぐに利用できるようにしたい!」という場合、後述の手順であらかじめ個人用サイトを作成しておくことが可能です。
SharePoint Online で管理者が個人用サイトを作成する方法
==============================================
SharePoint Online で管理者が個人用サイトを作成するには、ProfileLoader.CreatePersonalSiteEnqueueBulk メソッドを利用します。
上記メソッドは Visual Studio や PowerShell から実行できます。
1. Visual Studio を利用する方法
2. PowerShell を利用する方法
1. Visual Studio を利用する方法
------------------------------------------
下記の MSDN ページ内のサンプル コードを Visual Studio から実行してください。(変更が必要な個所はハイライトされている部分のみです!)
開発者向けの SharePoint 2013 のソーシャルおよびコラボレーション機能の新機能
https://msdn.microsoft.com/ja-jp/library/office/jj163783(v=office.15).aspx
---------- ここから ----------
複数ユーザー (SharePoint Online 上の 個人用サイト ホスト管理者のみ) 向けの個人サイトをプロビジョニングするには、ProfileLoader.CreatePersonalSiteEnqueueBulk メソッドを使用します。
個人用サイト ホスト管理者は ProfileLoader.CreatePersonalSiteEnqueueBulk メソッドを使用して、プログラムによって複数ユーザー向けの個人サイトを SharePoint Online 上にプロビジョニングできます。これには OneDrive for Business や [サイトの管理] ページなどの機能が含まれています。
次のコード例では、コンソール アプリケーションに .NET クライアント オブジェクト モデルを使用しています。この例を実行する前に、Microsoft.SharePoint.Client.dll、Microsoft.SharePoint.Client.Runtime.dll および Microsoft.SharePoint.Client.UserProfiles.dll への参照を追加し、userName、passwordStr、および serverUrl 変数のプレース ホルダー値を変更してください。serverUrl 変数は、SharePoint Online 管理センターのURL でなければなりません。
-----
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
namespace CreatePersonalSiteBulkConsole
{
class Program
{
static void Main(string[] args)
{
string userName = "administrator@contoso.onmicrosoft.com";
string passwordStr = "password";
string serverUrl = "https://contoso-admin.sharepoint.com/";
using (var clientContext = new ClientContext(serverUrl))
{
SecureString password = new SecureString();
Array.ForEach(passwordStr.ToCharArray(), c => password.AppendChar(c));
var credentials = new SharePointOnlineCredentials(userName, password);
clientContext.Credentials = credentials;
var web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
ProfileLoader loader = ProfileLoader.GetProfileLoader(clientContext);
if (loader == null)
{
throw new InvalidOperationException("Failed to get ProfileLoader");
}
string[] userEmails = { "usera@contoso.onmicrosoft.com", "userb@contoso.onmicrosoft.com" };
loader.CreatePersonalSiteEnqueueBulk(userEmails);
loader.Context.ExecuteQuery();
}
}
}
}
-----
メモ
必要なクライアント DLL を入手するために、SharePoint Online Client Components SDK をダウンロードしてください。
---------- ここまで ----------
メモに記載されているように、上記のコードを実行するには、Microsoft.SharePoint.Client.dll や Microsoft.SharePoint.Client.UserProfiles.dll などの参照を追加する必要があり、下記の SDK を予め Visual Studio を開始したコンピューター上にインストールする必要がありますのでご注意ください。
SharePoint Online Client Components SDK
https://www.microsoft.com/en-us/download/details.aspx?id=42038
2. PowerShell を利用する方法
----------------------------------------
下記の PowerShell スクリプトを実行することで、複数ユーザーの個人用サイトを管理者が一括で作成することが可能です。(変更が必要な個所はハイライトされている部分のみです!)
前述の SharePoint Online Client Components SDK を PowerShell を実行するコンピューターにインストールする必要がありますのでご注意ください。
-----
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
$webUrl = "https://contoso-admin.sharepoint.com/"
$username = "administrator@contoso.onmicrosoft.com"
$password = ConvertTo-SecureString -AsPlainText -String 'password' -Force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$web = $ctx.Web
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password)
$ctx.Load($web)
$loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)
$profile = $loader.GetUserProfile()
$ctx.Load($profile)
$ctx.ExecuteQuery()
$UserEmails = @("usera@contoso.onmicrosoft.com"),@("userb@contoso.onmicrosoft.com")
$loader.CreatePersonalSiteEnqueueBulk($UserEmails)
$loader.Context.ExecuteQuery()
-----
参考情報
========
ユーザーが [ニュース フィード] をクリックする前にプログラムによって正常に個人用サイトが作成されたことを確認するには、SharePoint 管理センターの [ユーザー プロファイル] から該当ユーザーのプロファイルの編集画面を開き、[個人用サイト] フィールドにパスが設定されていることをご確認ください。