Tuesday, 11 March 2014
Wednesday, 29 January 2014
Change Site Author /Site Owner using PowerShell
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
}
Sunday, 19 January 2014
“Sorry, something went wrong” error message when users try to Upload document to the Document Library.
This Error message occurs in a document library while uploading the document beacouse,
the document could have associated with custom properites,
Click on Properties of document for which u want to upload the document library.
If you are able to see any custom tab , remove all the custom properties and try to upload again ,
Hope it should fix the issue.
Tuesday, 7 January 2014
Delete Custom Master Page using PowerShell
cls
# Add the
Powershell snapin,
if
((Get-PSSnapin "Microsoft.SharePoint.PowerShell"
-ErrorAction SilentlyContinue)
-eq $null)
{
Add-PSSnapin
"Microsoft.SharePoint.PowerShell"
}
# Get the Name of the Website where we need to delete the
Custom Master Page from Master Page Library.
$web=Get-SPWeb "http://sedwdevrtm:22222/sites/Learning/"
# Note
assumption that seatle_manju.master is not a default master page , if its a
default master then we can't delete it
$lib=$web.GetFolder("_catalogs/masterpage").Files["seatle_manju.master"];
Write-Host
"Current library is " $lib
$lib.Delete();
$web.Dispose();
Add Existing List webpart to a Page using PowerShell
# Clear the Screen
Cls
# Add the
Powershell Ps Snap-in
if
((Get-PSSnapin "Microsoft.SharePoint.PowerShell"
-ErrorAction SilentlyContinue)
-eq $null)
{
Add-PSSnapin
"Microsoft.SharePoint.PowerShell"
}
# Create variable to check for existance of same list
webpart in the page , if i=0 means
webpart is not existing
$i=0
# Get the
website url
$web= Get-SPWeb -Identity "http://sedwdevrtm:22222/sites/demo1/"
# Mention the
List name that needs to be added in the page
$listName
= "Test2"
# Specify the
page url webpart that needs to be added
$pageUrl= "http://sedwdevrtm:22222/sites/demo1/SitePages/Home.aspx"
try
{
# Create New object of type XsltListViewWebPart
$webpart
= New-Object
Microsoft.SharePoint.WebPartPages.XsltListViewWebPart
$list=$web.Lists.TryGetList($listName)
#Assign
the Webart Listid with Current List Id i.e.. "list id that needs to be
added in the page"
$webpart.ListId = $list.ID
$webpartmanager= $web.GetLimitedWebPartManager($pageurl,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
# Loop
through all the webparts in the page and , Check if the List is already Exisiting if i = 1 means list with
that id is already exisiting.
foreach($wpt in $webpartmanager.WebParts)
{
#
Webpart List id is compared with List id to check for existance of webpart.
if($wpt.ListId -eq $list.ID)
{
$i=$i + 1
break
break
}
}
if($i -ne "0")
{
Write-Host
"List is already existing" $list.Title
}
else
{
write-host
"Library is not existing hence Added"
$webpartmanager.AddWebPart($webpart,"",0)
}
}
catch
[Exception]
{
Write-Host
$_.Exception.Message
}
Read the Page url's in the PageLibrary using Powershell SharePoint 2013
Read Pages from Page Library using Powershell SharePoint 2013
Cls
$web= Get-SPWeb -Identity http://sedwdevrtm:22222/sites/abcd/
# Site Pages is the Name of Library for Pages in SP2013
$lists=$web.Lists.TryGetList("Site Pages")
# Displays the list of Pages with Name from Page Library
Write-Host $lists.Items.Name
# Read Site Pages with URL's Library Pages
Write-Host $lists.Items.URLS
# Count of Pages in the Library Pages in SP2013
Write-Host $lists.Items.Count
Wednesday, 1 January 2014
MultiChoice CheckBox field using PowerShell
Create SPField Multichoice checkbox field using Powershell
# Read the Site
Url from User
$url = Read-host " Enter Name of the Site to Add Document
Library"
# get Website name
$OpenWeb = Get-SPWeb $url -ErrorVariable err -ErrorAction SilentlyContinue -AssignmentCollection $assignmentCollection
# Get the Document Library Name
$lib=$OpenWeb.Lists["DocumentLibraryName"]
# Create and xml field element to add multichoice values
$fldXml = "<Field
Type='MultiChoice' DisplayName='Document Status' Name='DocumentStatus' >
<CHOICES>
<CHOICE>Review
Required</CHOICE>
<CHOICE>Review in
Progress</CHOICE>
<CHOICE>Review
Completed</CHOICE>
</CHOICES>
</Field>"
$lib.Fields.AddFieldAsXml($fldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
$lib.Update()
that's set ........
OutPut:
Subscribe to:
Posts (Atom)

