質問

大丈夫私は半分眠っています、私のPowerShellスクリプトで何をしましたか(私はちょうど念頭に置いて修正されたもので修正しました)

function update-fields () {
#Set up default variables

#My Site URL
$mySiteUrl = "http://cia-central"

#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) 
$profiles = $profileManager.GetEnumerator()

    foreach ($up in $profiles) {
        Write-Host $up["UserName"].Value
        $firstname = $up["UserName"].Value
        $up["FirstName"].Value = $firstname
        $up["LastName"].Value = "Lynch"
        $up["Role"].Value = "Operative"
        $up["Entity"].Value = "CIA"
        $up["WorkPhone"].Value = "01234 568 901"
        $up["EMail"].Value = $firstname + ".lynch@cia.com"
        $up.Commit()
    }
}
.

[編集]サントス私はそれを含めたと思った、何が起こったのかわからない:

プロファイル変数はProfileManagerからNULLに戻っています。しかし、私の眠くされていると、私はエラーを読み、手がかりがそこにいました、私はアカウントの権限を持っていませんでした。

「ユーザプロファイルアプリケーションは、要求をサービスに利用可能な場合は利用可能」スクリプトを実行している最初の50回

完了

役に立ちましたか?

解決

The profiles variable is coming back NULL from the profilemanager. But in my sleepyness I re read the error and the clue was there, I didn't have the account permissions.

"No user profile application available to service the request" I just didn't see this error the first 50 times running the script.

Done.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top