Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$collabWebs
= Get-SPWebApplication "http://localdevrtm"
| Get-
SPSite -Limit All | where
{$_.Url like "http://test.dev.local/sites/qw*"}
SPSite -Limit All | where
{$_.Url like "http://test.dev.local/sites/qw*"}
$collabWebs
| % { $web = $_
if($web.IsRootWeb)
{
{
$NewAdmin = $web.EnsureUser("devuser\manju")
$NewAdmin .IsSiteAdmin =
$true
$NewAdmin .Update()
}
}
# collabwebs object contains list of Site urls from WebApp http://localdevrtm which starts with http://..../sites/qw*
#$_ is the Current object
# Url is property which has list of Sitecollections
# % is for looping through list of urls which we got from $collabwebs
# check if $web is a root web if so go ahead and add the SiteCollection Admininstrator
PowerShell script to Update SiteCollection Admin for Single SiteCollection
cls
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$site = Get-SPSite -Identity "http://test.dev.local/sites/qw"
if($web.IsRootWeb)
{
{
$NewAdmin = $web.EnsureUser("devuser\manju")
$NewAdmin .IsSiteAdmin = $true
$NewAdmin .Update()
}
{
Write-Host " Site Collection Admin is not updated "
}
No comments:
Post a Comment