This is an example PowerShell script to create a list view in SharePoint with a filter on a column
#Get destination site and list
$web = Get-SPWeb "https://site"
$list = $web.GetList(($web.ServerRelativeUrl.TrimEnd("/") + "/General"))
$viewTitle = "BE" #Title property
#Add the column names from the ViewField property to a string collection
$viewFields = New-Object System.Collections.Specialized.StringCollection
$viewFields.Add("DocIcon") > $null
$viewFields.Add("LinkFilename") > $null
$viewFields.Add("Modified") > $null
$viewFields.Add("Editor") > $null
$viewFields.Add("FileSizeDisplay") > $null
#Query property
$viewQuery = '<OrderBy><FieldRef Name="LinkFilename" /></OrderBy>
<Where><Eq><FieldRef Name="Country" /><Value Type="Text">BE</Value></Eq></Where>'
#RowLimit property
$viewRowLimit = 50
#Paged property
$viewPaged = $true
#DefaultView property
$viewDefaultView = $false
#Create the view in the destination list
$newview = $list.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)
Write-Host ("View '" + $newview.Title + "' created in list '" + $list.Title + "' on site " + $web.Url)
$web.Dispose()
Source: https://sharepoint.stackexchange.com/questions/158009/create-list-view-powershell-and-create-filter
Home / PowerShell /
SharePoint
/ SharePoint 2013 - Create list view with PowerShell and create filter
- Blogger Comment
Subscribe to:
Post Comments
(
Atom
)
Category
- Active Directory ( 8 )
- App Packaging ( 6 )
- BitLocker ( 9 )
- CrashPlan ( 7 )
- DNS ( 1 )
- DocLink ( 2 )
- Excel ( 3 )
- Exchange ( 7 )
- Group Policy ( 2 )
- Javascript ( 1 )
- M365 ( 5 )
- OneDrive ( 1 )
- OneNote ( 1 )
- Power Apps ( 1 )
- Power Automate ( 1 )
- Power BI ( 11 )
- PowerShell ( 54 )
- SCCM ( 28 )
- SCCM Device Collections ( 12 )
- SCCM Reports ( 12 )
- SCCM User Collection ( 2 )
- SCSM ( 4 )
- SharePoint ( 52 )
- SharePoint Design ( 20 )
- Skype for Business ( 1 )
- SQL Server ( 3 )
- SSL Certificates ( 3 )
- Teams ( 6 )
- Windows 10 ( 3 )
- Windows 7 ( 4 )
- Windows Server ( 5 )
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.