PowerShell for Microsoft SharePoint 2010 Administrators in Visual Studio .NET

Encoder QR Code ISO/IEC18004 in Visual Studio .NET PowerShell for Microsoft SharePoint 2010 Administrators

PowerShell for Microsoft SharePoint 2010 Administrators
QR Scanner In .NET Framework
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
Draw QR Code JIS X 0510 In .NET
Using Barcode generator for VS .NET Control to generate, create QR Code image in .NET framework applications.
Once we have a list item stored in a variable, we can get or set any of the field values available In the following example, we retrieve the list item s title
Decoding QR Code 2d Barcode In .NET Framework
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
Print Barcode In Visual Studio .NET
Using Barcode generation for Visual Studio .NET Control to generate, create bar code image in .NET applications.
PS > $spListItem["Title"] My new ListItem
Barcode Recognizer In .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
Creating QR Code JIS X 0510 In C#
Using Barcode maker for Visual Studio .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications.
We can change the list item s title by assigning a new value and calling the Update method
Make QR In .NET
Using Barcode generation for ASP.NET Control to generate, create QR-Code image in ASP.NET applications.
Making Denso QR Bar Code In Visual Basic .NET
Using Barcode encoder for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
PS > $spListItem["Title"] = "New Title" PS > $spListItemUpdate()
Make Code 39 Full ASCII In Visual Studio .NET
Using Barcode generator for Visual Studio .NET Control to generate, create ANSI/AIM Code 39 image in Visual Studio .NET applications.
Generate GS1 DataBar-14 In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create GS1 DataBar Limited image in .NET applications.
The GetItems method is better suited if you want to retrieve multiple items You can use the GetItems method without any input, which will return all list items Alternatively, you can use a CAML query to select specific list items To use a CAML query with the GetItems method, we first need to create an object of the type MicrosoftSharePointSPQuery
Create Barcode In .NET
Using Barcode generation for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
Encode USS-93 In Visual Studio .NET
Using Barcode encoder for .NET framework Control to generate, create Code 9/3 image in .NET applications.
PS > $spQuery = New-Object MicrosoftSharePointSPQuery
Printing Bar Code In None
Using Barcode generator for Online Control to generate, create bar code image in Online applications.
Generating Barcode In C#.NET
Using Barcode generation for .NET framework Control to generate, create barcode image in VS .NET applications.
The SPQuery object supports the Query property, which we use to place a CAML query Here s the CAML query we ll use in our example:
EAN13 Recognizer In Visual Basic .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
Read Barcode In C#
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET framework applications.
PS > $camlQuery = >> '<Where> >> <Eq> >> <FieldRef Name="YesNo" /> >> <Value Type="Text">True</Value> >> </Eq> >> </Where>' >>
Generating Barcode In VB.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create barcode image in .NET applications.
Generating Matrix Barcode In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create Matrix 2D Barcode image in ASP.NET applications.
We create a new query containing a Where statement using the <Where> tag Next, we specify an equals expression using the <Eq> tag For other types of searches, you can replace this tag with the appropriate one, such as <Lt> or <Gt> to search for list items where the value of this field is less than or greater than a value, respectively We then specify the field we want to query against using the <FieldRef> tag In this example, we want to look at the YesNo field in the list Finally, we use the <Value> tag to specify that the value type is Text and that the value should equal True Once we have created a CAML query and stored it in a variable, we assign it to the Query property of our SPQuery object
DataMatrix Drawer In Visual C#.NET
Using Barcode maker for VS .NET Control to generate, create ECC200 image in Visual Studio .NET applications.
Print EAN13 In Visual Studio .NET
Using Barcode generation for Reporting Service Control to generate, create European Article Number 13 image in Reporting Service applications.
PS > $spQueryQuery = $camlQuery
Before using the SPQuery with the GetItems method, we should specify the RowLimit property that is used to limit the amount of items returned per page
15:
Managing SharePoint List Items
If we run the SPQuery without setting the row limit, the query will select all items matching the criteria, and might fail on lists with a large number of items
PS > $spQueryRowLimit = 100
Here, we set the RowLimit property to 100 so that only 100 list items are returned per page The RowLimit value should be between 1 and 2000 Finally, we can call the GetItems method with the SPQuery object instance we created earlier for input
PS > $spListItemCollection = $spListGetItems($spQuery)
In this example, we retrieve list items wrapped up in a SPListItemCollection object and store this object in a variable We can now use the ForEach-Object cmdlet to iterate through the items and perform an action In the next example, we change the text in the Notes field to Updated using Windows PowerShell
PS >> >> >> > $spListItemCollection | ForEach-Object { $_["Notes"] = "Updated using Windows PowerShell" $_Update() }
The Get-SPListItem function uses a CAML query to retrieve list items where the value of a specified field equals the value assigned to the function s value parameter The following is the complete function
function Get-SPListItem ( [string]$url, [string]$field, [string]$value, [int]$rowLimit = 100 ) { # Use the Get-SPList function to retrieve a list $spList = Get-SPList -url $url # Create Query based on field and value $camlQuery = '<Where><Eq><FieldRef Name="' + $field + '"/><Value Type="' + $spListFields[$field]Type + '">' + $value + '</Value></Eq></Where>'; # SPQuery object $spQuery = New-Object MicrosoftSharePointSPQuery;
PowerShell for Microsoft SharePoint 2010 Administrators
# Add query $spQueryQuery = $camlQuery; # Set rowlimit $spQueryRowLimit = $rowLimit; return $spListGetItems($spQuery); }
You can use the function by typing the following:
PS > $spListItem = Get-SPListItem ` >> -url "http://nimaintranet/Lists/Custom List" ` >> -field Title -value "My List Item"
In this example, we use the Get-SPListItem function to retrieve all list items from the Custom List list where the Title field value equals My List Item Using the GetItems method without a CAML query returns a SPListItemCollection containing all items in the list The following is an example of this
PS > $spListItemCollection = $spListGetItems()
You can use the Where-Object cmdlet to retrieve individual list items from the SPListItemCollection that match specified criteria In the following example, we retrieve all list items where the value of the YesNo field equals True
PS > $spListItemCollection | Where-Object { $_["YesNo"] -eq "True" }
If we want to perform an action on the list items where the value of the YesNo field equals True, we can use the ForEach-Object cmdlet, as shown here:
PS > $spListItemCollection | Where-Object { $_["YesNo"] -eq "True" } | >> ForEach-Object { >> $_["Choices"] = "Third Choice" >> $_Update() >>}
In this example, we change the value of the Choices field to Third Choice NOTE When using the GetItems method without a CAML query, all the items in the list are read into memory; therefore, large lists may consume a lot of memory
Copyright © OnBarcode.com . All rights reserved.