powershell 将SharePoint用户添加到社区站点(SPWebtemplate)。基于XML输入文件。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 将SharePoint用户添加到社区站点(SPWebtemplate)。基于XML输入文件。相关的知识,希望对你有一定的参考价值。

<config>
	<community url="http://rbla-sp2010-002/communautes/communaute01">
	    <user id="rbla\rblanchard" />	
    </community>
</config>
# ----------------------------------------------
# Author: Romain Blanchard
# Date: 02.07.2014
# Description: Add SharePoint users to community site (SPWebtemplate). Based on XML input file.
# ----------------------------------------------

# -- Script -- #

# Foreach Community
Select-Xml -Path "users.xml" -Xpath "/config/community" | ForEach-Object { 
	
	$url = $_.Node.url
    write-host "--- Working on $web community ---" -foregroundcolor "Yellow"
    write-host ""
    $web = Get-SPWeb $url
    $memberslist = $web.Lists["Membres de la communauté"]

    ## Foreach users inside this community
    $_.Node | Select-Xml -Xpath "user" | ForEach-Object {
        $userid =  $_.Node.id
        $user = $web.EnsureUser($userid)

        write-host "Adding user $userid ..." -foregroundcolor "Yellow" -NoNewLine
        $userexistbool = $false

        ## Check if user already exist into this community        
        foreach ($item in $memberslist.Items)
        {
            ## If user already present set boolean to true
            if ($item["Title"] -eq $user.Name)
            {
                $userexistbool = $true
            }
        }

        if ($userexistbool -eq $true)
        {
            write-host " this user already exist." -foregroundcolor "Red"
        }

        ## If user not present, add it and leave the loop
        else
        {
            ## Add user to member list
            $memberItem = $memberslist.Items.Add()
            $memberItem["Title"] = $user.Name
            $memberItem["Member"] = $user
            $memberItem["MemberStatusInt"] = 1
            $memberItem.Update()

            ## Add user to Members Security group
            $membersGroup = $web.SiteGroups["Membres"]
            $membersGroup.AddUser($user)

            ## Increment property bag value
            $web.AllowUnsafeUpdates = $true
            $web.AllProperties["Community_MembersCount"] = ($memberslist.ItemCount)
            $web.Update()
            $web.AllowUnsafeUpdates = $false

            write-host " done!" -foregroundcolor "Green"
        }
    }
}

以上是关于powershell 将SharePoint用户添加到社区站点(SPWebtemplate)。基于XML输入文件。的主要内容,如果未能解决你的问题,请参考以下文章

powershell 将SharePoint用户添加到社区站点(SPWebtemplate)。基于XML输入文件。

powershell 将图片设置为SharePoint 2010用户配置文件(UPS),图片来自本地路径。

powershell 这将获取用户所属的SharePoint组,以用于给定站点。这使用用户的登录名进行比较。

sharepoint 2013:活动目录迁移用户后,在sharepoint中move 用户 powershell

powershell 这将通过活动目录和SharePoint直接权限提供用户列表。这是未完成的,需要一堆改进

powershell SharePoint PowerShell脚本,用于显示站点的用户和用户角色