I used this script as a base.
$ver = $host | select version if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"} if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $web = Get-SPWeb -Identity "http://portal/sites/Requests" $lists=$web.Lists["User Request", "Hardware Request", "Employee Request"] $SourceView="All Items" $NewViewName="Created By Me" $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 = "" $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() } $web.Dispose()
Hi Tobias,
ReplyDeletehttp:///_catalogs/users/simple.aspx
http:///_catalogs/users/detail.aspx
i want to update this views with new columns lets say Department and BU, i can do it manually but i have 400 site collections. i want to automate this process powershell,
any help ?
Please refer my post to create list, fields and view SharePoint list using powershell script:
ReplyDeletehttp://sharepointquicksolutions.blogspot.in/2014/06/create-sharepoint-list-using-powershell.html
http://sharepointquicksolutions.blogspot.in/2014/06/create-view-in-list-using-powershell.html
Please provide your valuable feedback.