Working with Site Collections in .NET

Draw QR Code in .NET Working with Site Collections

Working with Site Collections
QR Recognizer In .NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET applications.
Paint Denso QR Bar Code In .NET
Using Barcode generator for VS .NET Control to generate, create QR Code image in Visual Studio .NET applications.
When we run the function, the rows in the Excel spreadsheet are returned as custom objects, as shown in Figure 11-1
QR-Code Recognizer In .NET Framework
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
Encode Barcode In .NET
Using Barcode printer for VS .NET Control to generate, create barcode image in .NET framework applications.
Figure 11-1
Scan Barcode In Visual Studio .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in VS .NET applications.
Painting Quick Response Code In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create QR Code image in .NET framework applications.
Results of the Get-Excel function
QR Code Creator In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create Quick Response Code image in ASP.NET applications.
Print QR In VB.NET
Using Barcode printer for .NET framework Control to generate, create QR Code ISO/IEC18004 image in VS .NET applications.
Creating the Site Collections
GS1 DataBar-14 Encoder In Visual Studio .NET
Using Barcode maker for VS .NET Control to generate, create GS1 DataBar-14 image in VS .NET applications.
USS Code 39 Drawer In VS .NET
Using Barcode creator for VS .NET Control to generate, create Code 39 Full ASCII image in Visual Studio .NET applications.
We can store the output from the Get-Excel function in a variable that we can use to loop through each project and create a site collection using the New-SPSite cmdlet
EAN 13 Encoder In .NET
Using Barcode printer for .NET Control to generate, create UPC - 13 image in .NET applications.
Drawing OneCode In VS .NET
Using Barcode encoder for VS .NET Control to generate, create OneCode image in .NET applications.
PS > $projects = Get-Excel -file C:\Documents\projectxlsx
Data Matrix Creator In Visual C#.NET
Using Barcode encoder for VS .NET Control to generate, create Data Matrix 2d barcode image in .NET applications.
UPC Symbol Encoder In Java
Using Barcode generation for BIRT Control to generate, create UPC-A Supplement 5 image in BIRT reports applications.
TIP Windows PowerShell supports the Import-Csv and Export-Csv cmdlets, which let you work with comma-separated files This means that you can achieve the same result as demonstrated in the previous example by saving the Excel file as CSV and running $projects = Import-Csv -Path C:\Documents\projectcsv Now it is a simple procedure to create the site collections in SharePoint 2010 using the ForEach-Object cmdlet
Paint Data Matrix In Objective-C
Using Barcode creator for iPad Control to generate, create Data Matrix ECC200 image in iPad applications.
Generate GS1 - 13 In Objective-C
Using Barcode drawer for iPad Control to generate, create European Article Number 13 image in iPad applications.
PS >> >> >> > $projects | ForEach-Object { New-SPSite -url http://nimaintranet/sites/$($_'Project Name') ` -Name $($_'Project Name') -Description $($_'Project Description') ` -OwnerAlias $($_'Project Manager Logon Name') `
Create Code 39 Full ASCII In .NET
Using Barcode generation for Reporting Service Control to generate, create USS Code 39 image in Reporting Service applications.
GTIN - 12 Maker In Visual Studio .NET
Using Barcode generator for Reporting Service Control to generate, create UPCA image in Reporting Service applications.
PowerShell for Microsoft SharePoint 2010 Administrators
Barcode Drawer In None
Using Barcode creator for Font Control to generate, create bar code image in Font applications.
USS Code 128 Maker In .NET
Using Barcode generation for ASP.NET Control to generate, create Code 128 image in ASP.NET applications.
>> -Template "STS#0" >> } >> Url --http://nimaintranet/sites/tintrax http://nimaintranet/sites/Tin-tech http://nimaintranet/sites/Sildax http://nimaintranet/sites/Aplamlam http://nimaintranet/sites/Lattex http://nimaintranet/sites/Tincan http://nimaintranet/sites/Kaviar http://nimaintranet/sites/Lotphase http://nimaintranet/sites/Tinzennix http://nimaintranet/sites/Spanex
We go through each object stored in the $projects variable using the ForEachObject cmdlet Then we use the New-SPSite cmdlet to create new site collections, with the object property values as input Since the property names include spaces, we place the names within quotation marks As each New-SPSite command completes, the URL of the newly created site collection is displayed in the Windows PowerShell console
Creating Site Collections Based on Items in a SharePoint 2010 List
Another way to automate creation of site collections is to use information stored in a SharePoint 2010 list Before we dig into the script, let s take a look at the SharePoint 2010 list
Working with SharePoint 2010 Lists
We will use a custom list named Request Site that contains the items for new site collections Table 11-1 shows the columns in this custom list When creating a script that automates the creation of site collections in SharePoint 2010, we need a solution for detecting new items in the list If a new item exists in the list, we will create a site collection based on the item Let s go through this step by step First, we need to bind to the target SharePoint 2010 list We can do this using the GetList method of the SPWeb class, which accepts a list s URL as input
PS > $spWeb = Get-SPWeb -Identity "http://nimaintranet" PS > $spList = $spWebGetList("Lists/Request Site")
11:
Working with Site Collections
Column Name Site name Site description Site owner Department Cost center Project type
Column Type Changed name of the default Title column Multiple lines of text Person or group Single line of text Single line of text Choice (drop-down menu) Internal Vendor Partner Choice (drop-down menu) Requested Created Multiple lines of text
Status
Comment
Table 11-1 Custom Columns Created in the Request Site List
The Status field in the list will act as identifier of new items in this example If the status is set to Requested, the item will be processed by the script If the status is set to Created, the item will be skipped The Status field s default value is set to Requested, but how do we prevent users from changing the value to Created manually A simple but effective trick is to hide the field from the user Here s how to do this:
PS PS PS PS PS > > > > > $spField = $spListFields["Status"] $spFieldShowInNewForm = $False $spFieldShowInEditForm = $False $spFieldUpdate() $spField = $null
We create an instance of the SPField object and set the properties ShowInNewForm and ShowInEditForm to False We then make sure the changes persist in SharePoint by calling the Update method We can use the same approach for the Comment field, which will be used to add comments to each item
PowerShell for Microsoft SharePoint 2010 Administrators
Next, we store the list items in an array We use the Items property of the SPList object and pipe all list items to the Where-Object cmdlet to retrieve specific list items where the value of the Status field equals Requested
PS > $items = $spListItems | Where-Object { >> $_["Status"] -eq "Requested" }
NOTE When you use the Items property on an SPList object, all the list items in the list are read into memory, meaning that large lists may consume a lot of memory If you are working with large lists, it is a good idea to instead use the SPList object methods, such as GetItemById and GetItems, which support Collaborative Application Markup Language (CAML) queries You will see examples of how to work with list items using CAML queries and the GetItemById method in 15 This array contains all list items where the status equals Requested We can use the
Copyright © OnBarcode.com . All rights reserved.