PowerShell Script to change SiteOwner
Cls
# Add the PowerShell Snapin
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell"
-ErrorAction SilentlyContinue)
-eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
#Get the url of the website to change the Site Owner
$Url = "https://abc.com/sites/release/"
# New Author Name to be Changed
$Author=
"Local\Soreddy"
# Note : Get the
Userlogin name from UserProfile in Central Admin
try{
$Web = Get-SPWeb $Url
$Web.AllowUnsafeUpdates=$true
Write-Host "Current Author of site $Url" $Web.Author.DisplayName
$NewAuthor
= $Web.EnsureUser($Author);
$Web.Author = $NewAuthor;
$Web.Update();
$Web.AllowUnsafeUpdates=$false
Write-Host "New Author of site $Url" $Web.Author.DisplayName
}
catch{
$ErrorMessage
=$_.Excepction.Message
}
No comments:
Post a Comment