通过powershell创建“mysite”会引发错误

时间:2017-10-05 11:07:15

标签: sharepoint sharepoint-2013

我试图通过powershell创建一个“mysite”,但我遇到了一个错误,我很难找到答案。

这是我得到的错误:

  

New-Object:使用“1”参数调用“.ctor”的异常:“UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache没有c05da7c0-d405-4655-a7fa-08e271f4174d”

这是我的PS代码:

param
(
[Parameter(Mandatory=$true)]
[string]$username
)

asnp *sh*


$mysite = Get-SPSite "http://mysite.dev.loc"

$context = Get-SPServiceContext $mysite
$upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

#Create user profile
$profile = $upm.ResolveProfile($username)

if(!$profile)
{
Write-Host "$profile does not have a profile. Can't create personal site"
}

elseif($profile)
{
    if($profile.PersonalSite -eq $Null)
    {
     $profile.CreatePersonalSite()
     Write-Host "Personal site created"
    }
    else
    {
    Write-Warning "$username already has a personal site"
    }
}

1 个答案:

答案 0 :(得分:1)