PowerShell for Microsoft SharePoint 2010 Administrators in .NET framework

Printer QR Code 2d barcode in .NET framework PowerShell for Microsoft SharePoint 2010 Administrators

PowerShell for Microsoft SharePoint 2010 Administrators
QR-Code Reader In Visual Studio .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in .NET framework applications.
Encode Denso QR Bar Code In VS .NET
Using Barcode generation for VS .NET Control to generate, create QR image in VS .NET applications.
the Import-SPWeb cmdlet has an UpdateVersions parameter, which we can set to Ignore to import only items that do not exist in the list
Denso QR Bar Code Decoder In .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in VS .NET applications.
Barcode Creator In .NET Framework
Using Barcode creation for VS .NET Control to generate, create bar code image in VS .NET applications.
PS> Import-SPWeb http://nimaintranet -Path e:\backup\Documentscmp ` >> -IncludeUserSecurity -UpdateVersions Ignore
Bar Code Scanner In .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Print QR-Code In C#.NET
Using Barcode printer for .NET Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
The other possible values for the UpdateVersions parameter are Append and Overwrite The Export-SPWeb cmdlet has quite a few other parameters To display all the available parameters, type the following:
Denso QR Bar Code Encoder In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
Generate QR Code In VB.NET
Using Barcode printer for .NET framework Control to generate, create Denso QR Bar Code image in .NET applications.
PS > Get-Help Export-SPWeb -Parameter *
2D Barcode Creator In VS .NET
Using Barcode creation for .NET Control to generate, create Matrix Barcode image in VS .NET applications.
Generating EAN / UCC - 13 In .NET
Using Barcode generator for Visual Studio .NET Control to generate, create EAN 128 image in .NET framework applications.
Restoring Data from an Unattached Content Database
UPC A Drawer In .NET
Using Barcode encoder for VS .NET Control to generate, create UPC-A image in .NET applications.
Making USPS POSTNET Barcode In .NET
Using Barcode drawer for .NET Control to generate, create USPS POSTal Numeric Encoding Technique Barcode image in Visual Studio .NET applications.
Unattached content databases make it possible to connect content databases to a farm without affecting any of the Web applications To add a content database as unattached, use the Get-SPContentDatabase cmdlet with the ConnectAsUnattachedDatabase switch
EAN128 Decoder In VB.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
Paint Bar Code In None
Using Barcode creator for Font Control to generate, create barcode image in Font applications.
PS> $contentDB = Get-SPContentDatabase -DatabaseServer SQLServer01 ` >> -DatabaseName NimaIntra_ContentDB_01_Backup ` >> -ConnectAsUnattachedDatabase
Barcode Generator In Java
Using Barcode creation for Java Control to generate, create bar code image in Java applications.
Code 3 Of 9 Maker In .NET
Using Barcode creator for ASP.NET Control to generate, create ANSI/AIM Code 39 image in ASP.NET applications.
This example will store an instance of a SPContentDatabase object in the variable contentDB, which will allow us to work with the content inside the corresponding content database The database could also be a snapshot, as discussed earlier in the chapter Windows PowerShell does not include a cmdlet that exports sites, lists, or libraries from an unattached content database or snapshot, but that does not make it impossible to export such items Here, we ll go through the procedure, and then wrap it up in a function First, we create an instance of an SPExport object
Create Bar Code In None
Using Barcode maker for Office Excel Control to generate, create bar code image in Office Excel applications.
Draw EAN / UCC - 13 In None
Using Barcode drawer for Font Control to generate, create GS1 - 13 image in Font applications.
PS > $spExport = New-Object MicrosoftSharePointDeploymentSPExport
Encoding EAN 128 In .NET Framework
Using Barcode generator for Reporting Service Control to generate, create USS-128 image in Reporting Service applications.
Recognize GS1 - 12 In Visual Basic .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET framework applications.
The SPExportSettings class an instance of which is the value of the SPExport object s Settings property has a parameter called UnattachedContentDatabase, which enables us to target our unattached content database or snapshot
PS > $spExportSettingsUnattachedContentDatabase = $contentDB
We must set the absolute URL of the site that we want to restore, so we first need to find that information We can retrieve a specific site collection stored in the unattached content database using the Sites property
PS > $spSite = $contentDBSites["/"]
21:
Backup and Restore
Next, we use the AllWebs property to retrieve a specific site in the site collection and use the site s full URL as input to the SiteUrl parameter
PS > $SPExportSettingsSiteUrl= $spSiteAllWebs["/finance"]Url
We also set the file name and the location of the file, and choose to include the security settings
PS > $spExportSettingsBaseFilename = "Financecab" PS > $spExportSettingsFileLocation = "e:\backup\" PS > $spExportSettingsIncludeSecurity = "All"
There are additional properties that you can set to manage the export settings To display all of the available properties, type the following:
PS > $spExportSettings
Finally, we initiate the export operation using the Run() method
PS > $spExportRun()
This example generates a file containing a backup of the Finance site We can import the site using the Import-SPWeb cmdlet
PS> Import-SPWeb http://nimaintranet/finance -Path e:\backup\Financecab ` >> -IncludeUserSecurity -NoFileCompression
It is also possible to export subsites, lists, and even items The following function demonstrates how to export a single list from an unattached content database
function Export-SPUnattachedList( [string]$contentDatabase, [string]$databaseServer, [string]$site, [string]$web, [string]$list, [string]$file, [switch]$showSite, [switch]$showWeb, [switch]$showList ) { $ContentDB = Get-SPContentDatabase -DatabaseServer $DatabaseServer ` -DatabaseName $ContentDatabase -ConnectAsUnattachedDatabase if($showSite) { # Return site collections $contentDBSites | Select-Object -Property `
PowerShell for Microsoft SharePoint 2010 Administrators
@{Name="RelativeURL";Expression={([uri]$_Url)AbsolutePath}} Break } # Get site collection $spSite = $contentDBSites[$site] if($showWeb) { # Return sites $spSiteAllWebs | Select-Object -Property ` @{Name="RelativeURL";Expression={([uri]$_Url)AbsolutePath}} Break } # Get site $spWeb = $spSiteOpenWeb($web) if($showList) { $spWebLists | Select-Object -Property @{Name="List";Expression={$_Title}} Break } # Check folder if(-not(Test-Path (Split-Path $file))) { New-Item -path (Split-Path $file) -type directory | Out-Null } # Check if file already exists if(Test-Path $file) { Write-Host "File $file already exists" Break } $spList = $spWebLists[$list] $spExportObject = New-Object MicrosoftSharePointDeploymentSPExportObject $spExportObjectID = $SPListID $spExportObjectType = "List" $spExport = New-Object MicrosoftSharePointDeploymentSPExport # Add content database $spExportSettingsUnattachedContentDatabase = $ContentDB # Add object type $spExportSettingsExportObjectsAdd($spExportObject) # Add site collection URL $spExportSettingsSiteUrl= $spSiteURL # Set additional properties $spExportSettingsBaseFilename = (Split-Path $file -Leaf) $spExportSettingsFileLocation = (Split-Path $file) $spExportSettingsLogFilePath = ($file -Replace "\*","-logtxt") $spExportSettingsIncludeSecurity = "All"
21:
Backup and Restore
$spExportSettingsIncludeVersions = "All" # Initiate export operation $spExportRun() # Dispose objects $spWebDispose() $spSiteDispose() $spExportDispose() }
You can run the function by typing the following:
PS > Export-SPUnattachedList -contentDatabase NimaIntra_ContentDB_01_Backup ` >> -databaseServer SQLServer01 -site "/" -web /finance ` >> -list Announcements -file C:\Backup\financecab
If you are uncertain of the site collections available, you can use the showSite switch parameter:
PS > Export-SPUnattachedList -contentDatabase NimaIntra_ContentDB_01_Backup ` >> -databaseServer SQLServer01 -showSite
If you know the site collection but want to find out which sites and subsites are available in the unattached content database, use the showWeb switch parameter
PS > Export-SPUnattachedList -contentDatabase NimaIntra_ContentDB_01_Backup ` >> -databaseServer SQLServer01 -site "/" -showWeb
Finally, if you want to find out which lists are available on a site stored in an unattached content database, you can use the showList switch parameter
PS > Export-SPUnattachedList -contentDatabase NimaIntra_ContentDB_01_Backup ` >> -databaseServer SQLServer01 -site "/" -web /finance -showList
NOTE Backup and restore operations might affect the performance of your SharePoint 2010 environment It is recommended that you perform them outside business hours
Copyright © OnBarcode.com . All rights reserved.