Powershell:
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
#$groupName="Emp-Directory"
#$permLevel="Edit"
function AddGroupToSite($url, $groupName, $permLevel)
{
$web = Get-SPWeb -Identity $url
$web.RootWeb.SiteGroups.Add($groupName, $web.Owner, $web.Owner, "Custom Group")
$ownerGroup = $web.SiteGroups["Finance_ACL_New_Delet"]
$ownerGroup.AllowMembersEditMembership = $true
$ownerGroup.Update()
write-host $newGroup -foregroundcolor green
$web.Update()
$web.Dispose()
}
function GenerateAllSitecollectionsInWebapplication ($url)
{
write-host "Sitecollection List Extraction started...." -foregroundcolor red
try
{
$Site=Get-SPSite $url
$spWebApp = $Site.WebApplication
$TotalList = @()
write-host "Below is the list of all sitecollections for webapplication" + $spWebApp + "..." -foregroundcolor red
foreach($allsites in $spWebApp.Sites)
{
$list = $allsites.url
write-host $list -foregroundcolor blue
AddGroupToSite -url $list -groupName "Emp-Directory" -permLevel "Edit"
}
}
catch
{
write-host "Unable to Extract Sitecollection List..." -foregroundcolor red
break
}
}
GenerateAllSitecollectionsInWebapplication -Url "http://raghuspsserver/"
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
#$groupName="Emp-Directory"
#$permLevel="Edit"
function AddGroupToSite($url, $groupName, $permLevel)
{
$web = Get-SPWeb -Identity $url
$web.RootWeb.SiteGroups.Add($groupName, $web.Owner, $web.Owner, "Custom Group")
$ownerGroup = $web.SiteGroups["Finance_ACL_New_Delet"]
$ownerGroup.AllowMembersEditMembership = $true
$ownerGroup.Update()
write-host $newGroup -foregroundcolor green
$web.Update()
$web.Dispose()
}
function GenerateAllSitecollectionsInWebapplication ($url)
{
write-host "Sitecollection List Extraction started...." -foregroundcolor red
try
{
$Site=Get-SPSite $url
$spWebApp = $Site.WebApplication
$TotalList = @()
write-host "Below is the list of all sitecollections for webapplication" + $spWebApp + "..." -foregroundcolor red
foreach($allsites in $spWebApp.Sites)
{
$list = $allsites.url
write-host $list -foregroundcolor blue
AddGroupToSite -url $list -groupName "Emp-Directory" -permLevel "Edit"
}
}
catch
{
write-host "Unable to Extract Sitecollection List..." -foregroundcolor red
break
}
}
GenerateAllSitecollectionsInWebapplication -Url "http://raghuspsserver/"
No comments:
Post a Comment