The Sitecore Razl scripting engine has been completely re-designed. Sitecore Razl now uses PowerShell to script Razl operations. In most cases, the hig-level Razl script functions will allow developers to accomplish everything they need to. Sitecore Razl offers developers the oppertunity to directly interface with the Sitecore Razl service through PowerShell. This offeres developers the oppertunity to script complex migration scenarios using Powershell.
It is recommended that the developer is familiar with creating connections described in Sitecore Razl PowerShell Connections before attempting to use any of these Cmdlets.
Sitecore Razl provides the developers with a cmdlets to get items and information about items from a Sitecore server. The Cmdlets return data structures that can be manipulated by PowerShell script to provide the developer with nearly unlimited flexibility in handling Sitecore items.
The Get-RazlChildItems cmdlet queries the Sitecore database for items under an item. The result of the cmdlet is an array of ItemProperties objects. These objects refer to the items under the item specified by the -ParentItemID parameter.
Summary of parameters:
The resulting ItemProperties object has the following properties:
The following is an example of using the Get-RazlChildItems Cmdlet to get items under Home:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlChildItems -Connection $connection -ParentItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
The Get-RazlField cCmdlet gets a FieldData object for a field on an Item on the Sitecore server.
Summary of parameters:
The cmdlet returns a FieldData object. The FieldData object has the following properties:
The following is an example of using the Get-RazlField cmdlet to get the the Text field on the Home item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlField -conection $connection -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -FieldID "{A60ACD61-A6DB-4182-8329-C957982CEC74}" -LanguageId "en" -VersionNum 1 -verbose
The Get-RazlFieldBlob cmdlet gets the value of a Blob field. The result can be returned as a byte array or stored in a file.
Summary of parameters:
The following is an example of using the Get-RazlFieldBlob Cmdlet to get the Blob field on the Google Plus media item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlField -conection $connection -ItemID "{A5A23083-C229-47EC-B1BC-445F8BBB55AB}" -FieldID "{40E50ED9-BA07-4702-992E-A912738D32DC}" -verbose
The Get-RazlItem Cmdlet gets an ItemDetails object or an array of ItemDetails objects from a server. The ItemDetails object contains all information about an item. This includes all fields for all languages and versions. The ItemDetails object is the object used internally by Razl to copy items between servers.
Summary of parameters:
See Manipulating ItemDetails below for the ItemDetails structure.
The following is an example of using the Get-RazlItem cmdlet to get the ItemDetails for the Home item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlItem -Connection $source -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
The Get-RazlReferencedItems cmdlet returns an array of ItemProperties objects representing the items referenced by the specified item.
Summary of parameters:
The following is an example of using the Get-RazlReferencedItems cmdlet to get the referenced items for the Home item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlReferencedItems -Connection $source -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
The Get-RazlReferredItems cmdlet returns an array of ItemProperties objects representing the items referring to the specified item.
Summary of parameters:
The following is an example of using the Get-RazlReferredItems cmdlet to get the items referring to the Home item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlReferredItems -Connection $source -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
Sitecore Razl offers the developer the ability to update items on a Sitecore server through a number of cmdlets. These cmdlets accept data structures that can be manipulated by PowerShell scripts.
The Set-RazlField cmdlet accepts a FieldData object and uses the information in the FieldData object to update an item on a Sitecore server.
Summary of parameters:
The following is an example of using the Set-RazlField cmdlet to update the Text field of the Home item:
$source = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
$target = Get-RazlConnection -SitecoreWebUrl http://target.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Target Sitecore"
$fieldData = Get-RazlField -Connection $source -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -FieldID "{A60ACD61-A6DB-4182-8329-C957982CEC74}" -LanguageId "en" -VersionNum 1 -verbose
Set-RazlField -Connection $target -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -FieldID "{A60ACD61-A6DB-4182-8329-C957982CEC74}" -LanguageId "en" -VersionNum 1 -FieldData $fieldData -verbose
The Set-RazlFieldBlob cmdlet accepts a byte array or filename and updates a blob field on an item on a Sitecore server.
Summary of parameters:
The following is an example of using the Set-RazlFieldBlob cmdlet to update the Blob field of the Google Plus media item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Set-RazlFieldBlob -Connection $source -ItemID "{A5A23083-C229-47EC-B1BC-445F8BBB55AB}" -FieldID "{40E50ED9-BA07-4702-992E-A912738D32DC}" -FieldBytes $bytes -verbose
The Set-RazlItem cmdlet pushes an ItemDetails object or an array of ItemDetails objects to a server. This allows the PowerShell script to update multiple items on the target server with a single command.
Summary of parameters:
See Manipulating ItemDetails below for the ItemDetails structure.
The following is an example of using Set-RazlItem to copy the Home item from the source server to the target server:
$source = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
$target = Get-RazlConnection -SitecoreWebUrl http://target.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Target Sitecore"
$itemDetails = Get-RazlItem -Connection $source -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -verbose
Set-RazlItem -Connection $target -ItemDetails $itemDetails -verbose
The Set-RazlItemTemplate updates the Template ID of the item specified by the ItemID on the server.
Summary of parameters:
The following is an example of using Set-RazlItemTemplate to update the Template Id of the Home item:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Set-RazlItemTemplate -ItemID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -TemplateID "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
Sitecore Razl provides cmdlets to allow PowerShell scripts to manipulate items on a Sitecore server.
The Move-RazlItem cmdlet moves a Sitecore item from one location in the content tree to another.
Summary of parameters:
The following is an example of using Move-RazlItem the Home item to the root of the Media Library folder:
Move-RazlItem -connection $connection -ItemId "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -NewParentId "{3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1}"
The Remove-RazlItem removes a Sitecore item from the target server. The item can be moved to the recycle bin or permenantly deleted.
Summary of parameters:
The following is an example of using Remove-RazlItem the Home item from the server:
Remove-RazlItem -connection $connection -ItemId "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
Sitecore Razl uses a number of different queries to assist the developer. Those queries have been exposed to PowerShell with the cmdlets below.
The Get-RazlDeepCompareResults cmdlet performs the same comparison as the Razl Deep Compare function. It starts at a single Sitecore item and compares the item and all items below it in the content trees on the source and target servers. The results are returned as an array of DeepCompareResult objects. These objects can be passed to other PowerShell cmdlets using the pipeline functions.
Summary of parameters:
The cmdlet returns an array of DeepCompareResult objects. The DeepCompareResult object has the following properties:
The following is an example of comparing everything under the default Home item on two servers.
Get-RazlDeepCompareResults -source $source -target $target -RootItemId "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
The Get-RazlHistory cmdlet returns a list of recent changes to the server. These changes are determined by looking at the history table, if enabled, or looking at the updated field on items. The change list can be filtered by date. The results are returned as an array of ChangeHistoryDetails objects.
Summary of parameters:
The cmdlet returns an array of ChangeHistoryDetails objects. The ChangeHistoryDetails object has the following properties:
The following is an example of getting the history of changes over the last 5 days:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
$last5Days = (Get-Date).AddDays(-5)
Get-RazlHistory -connection $connection -from $last5Days
The Search-RazlItems cmdlet uses the content index of the target Sitecore server to search for items on the server. Found items are returned as an array of ItemProperties.
Summary of parameters:
Please see Get-RazlChildItems for more information about the ItemProperties object.
The following is an example of searching for some text in Sitecore:
$results = Search-RazlItems -Connection $connection -SearchText "Sitecore"
The Get-RazlItem and Set-RazlItem cmdlets use the ItemDetails object to get and set items on the server. The ItemDetails object contains all field values for an item along with any known item meta-data. The ItemDetails object can be used to create or update existing items. The ItemDetails object returned by the the Get-RazlItem cmdlet contains everything needed by the Set-ItemDetails cmdlet to update an item on a server.
The Razl scripting library provides a few simple cmdlets to allow the developer to manipulate the ItemDetails object. This allows the developer virtually unlimited flexibility to manipulate Sitecore items. This flexibility facilitates many upgrade/migration scenarios.
The ItemDetails object contains the following properties:
The ItemDetails object exposes the following methods:
The FieldInfo object contains the following properties:
The FieldInfo object exposes the following methods:
The FieldInfoVersioned object holds all field values for all languages for a specific version. The object contains the following properties:
The FieldInfoVersioned object exposes the following methods:
The FieldLanguageInfo object holds all field values for a specific language. The object containes the following properties:
The FieldLanguageInfo object exposes the following methods:
The ItemProperties object contains the following properties:
The New-RazlItem cmdlet creates a new ItemDetails object with the specified name, Template, Parent and ID. This object can be passed to Set-RazlItem to create/update an item on a Sitecore server.
Summary of parameters:
Returns an ItemDetails object. See above for more information about the ItemDetails object.
The following is an example of using the ItemDetails cmdlets to create a new item:
#Create the new item
$newItem = New-RazlItem -Name $csvRow."Display Name" -ParentItemID $rootFolderId -TemplateID $csvImportTemplateId
# Add the fields to the item
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvTitleField -Value $csvRow.Title -Language "en" -Version 1)
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvContentField -Value $csvRow.Content -Language "en" -Version 1)
The New-RazlField cmdlet creates a new FieldInfo object with the specified Field ID.
Summary of parameters:
Returns a FieldInfo object. See above for more information about the FieldInfo object.
The following is an example of using the ItemDetails cmdlets to create a new item:
#Create the new item
$newItem = New-RazlItem -Name $csvRow."Display Name" -ParentItemID $rootFolderId -TemplateID $csvImportTemplateId
# Add the fields to the item
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvTitleField -Value $csvRow.Title -Language "en" -Version 1)
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvContentField -Value $csvRow.Content -Language "en" -Version 1)
The Add-RazlField cmdlet adds a FieldInfo to an ItemDetails object. The field is added to the correct collection of fields based on the Language and Version of the field. i.e. if Language and Version of the field is null, it’s a shared field. If language is “en” and version is 1, the item is added to the VersionedFields collection with a version of 1 and the english language.
Summary of parameters:
The following is an example of using the ItemDetails cmdlets to create a new item:
#Create the new item
$newItem = New-RazlItem -Name $csvRow."Display Name" -ParentItemID $rootFolderId -TemplateID $csvImportTemplateId
# Add the fields to the item
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvTitleField -Value $csvRow.Title -Language "en" -Version 1)
Add-RazlField -ItemDetails $newItem -FieldInfo $(New-RazlField -FieldID $csvContentField -Value $csvRow.Content -Language "en" -Version 1)
The Remove-RazlField cmdlet removes a field from an ItemDetails object. It will field the field and remove it based on the search criteria supplied.
Summary of parameters:
The cmdlets in the section provide some functionality used by Razl that could be useful in some scripts, but don’t really fit into any specific category.
The Clear-RazlCache cmdlet clears all Sitecore caches on the server. Pleae note: This operation can cause performance degradation of the server while the cache is re-populating, and should be used with care.
Summary of parameters:
This is an example of using Clear-RazlCache to clear caches on a server:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Clear-RazlCache -Connection $connection
The Get-RazlDatabaseNames cmdlet retrieves an array of strings representing the names of the databases available on the Sitecore server.
Summary of parameters:
The result of the cmdlet is an array of strings representing the database names on the server.
This is an example of using Clear-RazlCache to clear caches on a server:
$connection = Get-RazlConnection -SitecoreWebUrl http://source.sc.local -DatabaseName master -AccessGuid "00000000-1111-2222-3333-444444444444" -Name "Source Sitecore"
Get-RazlDatabaseNames -Connection $connection