共用方式為


Disabling SharePoint 2010 MySite creation through PowerShell

 

A colleague of mine and I were mucking about with PowerShell recently and came up with the following script to disable MySite creation for all Authenticated users.

This setting is on by default as well as most of the other social features and in a large organisation you would want to turn this setting off and have a controlled rollout of MySites.

Enjoy!

 #Add the required SP2010 snapins
Add-PSSnapIn Microsoft.SharePoint.PowerShell -EA 0
#Disables the right - Create Personal site for all authenticated users

#Dont forget to disable self service site creation for the MySite web app - https://technet.microsoft.com/en-us/library/ee624362.aspx#enableselfsvc

function DisableMySiteCreation([string]$UserProfileProxyName)
{
    $upaproxy = Get-SPServiceApplicationProxy | Where-Object {$_.DisplayName -eq $UserProfileProxyName} 
  $upasecurity = Get-SPProfileServiceApplicationSecurity -ProfileServiceApplicationProxy $upaproxy
  $authuser = New-SPClaimsPrincipal -Identity 'c:0(.s|true' -IdentityType EncodedClaim
  Revoke-SPObjectSecurity -Identity $upasecurity -Principal $authuser -Rights "Create Personal Site"
  Set-SPProfileServiceApplicationSecurity -Identity $upasecurity -ProfileServiceApplicationProxy $upaproxy
}
DisableMySiteCreation "User Profile Service Application Proxy" ##Replace accordingly with your proxy name