#-------------------------------------------------------------------------------------------------------------------------
# Author: Shiv Mangal Singh
# Date: Dec 23, 2015
# Description:
# 1. This script is used to add users in SharePoint Group.
# Syntax: here user.txt is the file name it contains users list(r1-core\xyz...etc) for adding.
#
# e.g: .\Add_Users_SharePoint_Group.ps1
#--------------------------------------------------------------------------------------------------------------------------------------------
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$data = Get-Content "D:\PS\user.txt"
$siteCollUrl = "https://ms.contoso.net/global/testurl/"
write-host $siteCollUrl
#$group = "Approvers"
$web = Get-SPWeb -identity $siteCollUrl
$groupName = $web.SiteGroups["testurl Visitors "]
write-host $grp
# Get users LAN ID from user.txt file
foreach ($User in $data)
{
$username = $web.Site.RootWeb.EnsureUser($User)
$groupName.AddUser($username)
Write-Host -ForegroundColor green $username "User Added Successfully";
}
# Author: Shiv Mangal Singh
# Date: Dec 23, 2015
# Description:
# 1. This script is used to add users in SharePoint Group.
# Syntax: here user.txt is the file name it contains users list(r1-core\xyz...etc) for adding.
#
# e.g: .\Add_Users_SharePoint_Group.ps1
#--------------------------------------------------------------------------------------------------------------------------------------------
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$data = Get-Content "D:\PS\user.txt"
$siteCollUrl = "https://ms.contoso.net/global/testurl/"
write-host $siteCollUrl
#$group = "Approvers"
$web = Get-SPWeb -identity $siteCollUrl
$groupName = $web.SiteGroups["testurl Visitors "]
write-host $grp
# Get users LAN ID from user.txt file
foreach ($User in $data)
{
$username = $web.Site.RootWeb.EnsureUser($User)
$groupName.AddUser($username)
Write-Host -ForegroundColor green $username "User Added Successfully";
}
No comments:
Post a Comment