1) Run script in
windows power shell first run line
Add-PSSnapin
‘Microsoft.SharePoint.PowerShell’
2) Change Display
name of column of list using power shell
$mySiteUrl
= "http://dev-tayyab:27262"
$spSite
= Get-SPSite -Identity $mySiteUrl
$spWeb
= $spSite.OpenWeb()
$list
= $spWeb.Lists[“ListForUpdateColumn”]
Write-Host
$list
$col
= $list.Fields["FirstName"]
$col.Title
= "NewName"
$col.Update()
Write-Host $col.Title
3) Create Views in
multiple lists using power shell
$mySiteUrl =
"http://dev-tayyab:27262"
$spSite = Get-SPSite -Identity $mySiteUrl
$spWeb = $spSite.OpenWeb()
$lists=$web.Lists["User Request",
"Hardware Request",
"Employee Request"]
$SourceView="All Items"
$NewViewName="Created By Tayyab"
$NewViewDefault=$true
foreach($list in $lists)
{
$view =
$list.Views[$SourceView]
$Viewfields =
$list.Views[$SourceView].ViewFields.ToStringCollection()
$viewRowLimit="100"
$viewPaged=$true
$viewDefaultView=$NewViewDefault
#
Setting the Query for the View
$viewQuery = "<orderby><fieldref
ascending="" false="" id=""
name=""></fieldref></orderby><where><eq><fieldref
author="" name=""><value integer=""
type=""><userid integer=""
type=""></userid></value></fieldref></eq></where>"
$viewName = $NewViewName
#
Finally – Provisioning the View
$myListView = $list.Views.Add($viewName,
$viewFields, $viewQuery, 100, $True, $False, "HTML", $False)
# You
need to Update the View for changes made to the view
# Updating the List is not enough
$myListView.DefaultView = $True
$myListView.Update()
$list.Update()
}
Write-Host $spWeb
0 comments:
Post a Comment