PowerShell – opret MySites til alle brugere
Et PowerShell-script fra TechNet Gallery, der opretter en personlig site på forhånd til hver brugerprofil i SharePoint.
Jeg har fundet ud af, at det her script er det mest effektive til at oprette MySites på forhånd til alle brugere.
1#---------------------------------------------------------------------------------
2#The sample scripts are not supported under any Microsoft standard support
3#program or service. The sample scripts are provided AS IS without warranty
4#of any kind. Microsoft further disclaims all implied warranties including,
5#without limitation, any implied warranties of merchantability or of fitness for
6#a particular purpose. The entire risk arising out of the use or performance of
7#the sample scripts and documentation remains with you. In no event shall
8#Microsoft, its authors, or anyone else involved in the creation, production, or
9#delivery of the scripts be liable for any damages whatsoever (including,
10#without limitation, damages for loss of business profits, business interruption,
11#loss of business information, or other pecuniary loss) arising out of the use
12#of or inability to use the sample scripts or documentation, even if Microsoft
13#has been advised of the possibility of such damages
14#---------------------------------------------------------------------------------
15
16Function New-OSCPersonlSite
17{
18<#
19 .SYNOPSIS
20 New-OSCPersonlSite is an advanced function which can be used to create personal site for each user in a SharePoint site.
21 .DESCRIPTION
22 New-OSCPersonlSite is an advanced function which can be used to create personal site for each user in a SharePoint site.
23 .PARAMETER SiteUrl
24 The specified site URL.
25 .EXAMPLE
26 C:\PS> New-OSCPersonlSite -SiteURL "http://sp2010:8888/sites/TopSite2"
27
28This command shows how to create personal site for each user in site "http://sp2010:8888/sites/TopSite2".
29#>
30 [CmdletBinding()]
31 Param
32 (
33 [Parameter(Mandatory = $True,Position=0)]
34 [String]$SiteURL
35 )
36 #Add "Microsoft.SharePoint.PowerShell" Snapin
37 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
38 {
39 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
40 }
41 #Load "Microsoft.Office.Server" Assembly
42 [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") | Out-Null
43 #Get SharePoint site
44 $Site = Get-SPSite -Identity $SiteURL
45 #Get service context
46 $context = Get-SPServiceContext -Site $site
47 $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
48 $AllProfiles = $upm.GetEnumerator()
49 #Create personal site for each user
50 foreach($profile in $AllProfiles)
51 {
52 $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
53 Try
54 {
55 if($profile.PersonalSite -eq $Null)
56 {
57 write-host "Creating personel site for $AccountName"
58 $profile.CreatePersonalSite()
59 write-host "Personal Site Admin has assigned"
60 }
61 else
62 {
63 Write-Warning "$AccountName already has personel site"
64 }
65 }
66 Catch
67 {
68 Write-Error "Failed to create personal site for '$AccountName'"
69 }
70 }
71 $Site.Dispose();
72}
73New-OSCPersonlSite -SiteURL "http://intranet/mysites/profile"
Kilde: http://gallery.technet.microsoft.com/office/Pre-Provision-SharePoint-ec781ee9