通过 powershell 创建 "mysite" 会抛出错误

Creating "mysite" through powershell throws error

我正在尝试通过 powershell 创建 "mysite",但我 运行 遇到一个错误,我很难找到答案。

这是我得到的错误:

New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have 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"
    }
}

看着这个https://social.technet.microsoft.com/Forums/office/en-US/d8ee4f32-c380-4d1d-9f26-59765aae4a7f/getting-errors-when-i-try-to-create-newobject-for-userprofile-manager-powershell-sharepoint-2010?forum=sharepointadminprevious

这看起来像是权限问题。以管理员身份尝试 运行 并 运行 程序本身具有管理员权限。