Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions samples/Advanced/Export.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$ExportSettings,

# The available actions to perform during the export
[ValidateSet('All','Solutions','Export-CrmSolutions','Expand-CrmSolutions','Edit-CrmSchemaFile','Expand-CrmData')]
[ValidateSet('All','Solutions','Data','Export-CrmSolutions','Expand-CrmSolutions','Edit-CrmSchemaFile','Expand-CrmData')]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export-CrmData needs to be added to this list.

[string[]]
$Actions = 'All'
)
Expand All @@ -35,6 +35,10 @@ if($settings.CrmSchemaSettings -and ('All' -in $Actions -or 'Edit-CrmSchemaFile'
$settings.CrmSchemaSettings | Edit-CrmSchemaFile
}

if($settings.ExtractData -and ('All' -in $Actions -or 'Expand-CrmData' -in $Actions) -and (Test-Path -Path $settings.ExtractData.ZipFile)) {
if($settings.ExportData -and ('All' -in $Actions -or 'Data' -in $Actions -or 'Export-CrmData' -in $Actions) -and (Test-Path -Path $settings.ExportData.SchemaFile)) {
$settings.ExportData | Export-CrmData
}

if($settings.ExtractData -and ('All' -in $Actions -or 'Data' -in $Actions -or 'Expand-CrmData' -in $Actions) -and (Test-Path -Path $settings.ExtractData.ZipFile)) {
$settings.ExtractData | Expand-CrmData -Verbose
}
8 changes: 8 additions & 0 deletions samples/Advanced/ExportSettings/Full.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ $projectRoot = Split-Path -Parent $scriptsRoot
account = {$_ -in 'accountid','parentaccountid'} # only export accountid and parentaccountid fields
}
}

# ExportData is used by export.ps1. Defines configuration data schema file to use for export and the zip file to put the data in.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is not consistent, is sometimes using spaces and other times is using tabs. Please use spaces since the existing code already uses them.

ExportData = [PSCustomObject]@{
CrmConnectionParameters = $CrmConnectionParameters
SchemaFile ="$projectRoot\temp\export\schema.xml"
ZipFile = "$projectRoot\temp\export\FabrikamFiberData.zip"
}

ExtractData = [PSCustomObject]@{
ZipFile = "$projectRoot\temp\export\FabrikamFiberData.zip"
Folder = "$projectRoot\crm\data\FabrikamFiber"
Expand Down
3 changes: 2 additions & 1 deletion src/Adoxio.Dynamics.DevOps/Adoxio.Dynamics.DevOps.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ ProcessorArchitecture = 'None'

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
@{ModuleName='Microsoft.Xrm.Data.Powershell'; ModuleVersion='2.8.0'; Guid='7df9c140-65c3-4862-b3bc-73fad633aae4'}
@{ModuleName='Microsoft.Xrm.Data.Powershell'; ModuleVersion='2.8.0'; Guid='7df9c140-65c3-4862-b3bc-73fad633aae4'},
@{ModuleName='Microsoft.Xrm.Tooling.ConfigurationMigration'; ModuleVersion='1.0.0.44'; Guid='162392C2-EDE9-4754-B5A3-7DE42E5C768C'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make spacing consistent per other comments.

)

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
Expand Down
44 changes: 44 additions & 0 deletions src/Adoxio.Dynamics.DevOps/Adoxio.Dynamics.DevOps.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,50 @@ function CreateRootSchema {

return $rootSchema
}
<#
.Synopsis
Exports configuration data from CRM organization into a DataMigration utility compatible zip file.
.DESCRIPTION
This function exports CRM data based on supplied configuration migration schema file settings saves it to a zip file.
.EXAMPLE
>
$CrmConnectionParameters = @{
OrganizationName = 'contoso'
ServerUrl = 'http://dyn365.contoso.com'
Credential = [PSCredential]::new("contoso\administrator", ("pass@word1" | ConvertTo-SecureString -AsPlainText -Force))
}

$SchemaFile = "C:\myproj\schema.xml"

$ZipFile = "C:\temp\export\mydata.zip"

Export-CrmData -CrmConnectionParameters $CrmConnectionParameters -SchemaFile $SchemaFile -ZipFile $ZipFile -DisablePl
#>
function Export-CrmData{
param (
[Parameter(
ValueFromPipelineByPropertyName=$true,
Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[hashtable]
$CrmConnectionParameters,

[ValidateNotNullOrEmpty()]
[Parameter(ValueFromPipelineByPropertyName=$true)]
[string]$SchemaFile,

[ValidateNotNullOrEmpty()]
[Parameter(ValueFromPipelineByPropertyName=$true)]
[string]$ZipFile
)
process
{
$CrmConnection = Get-CrmConnection @CrmConnectionParameters

Export-CrmDataFile -CrmConnection $CrmConnection -SchemaFile $SchemaFile -DataFile $ZipFile
}

}

function ExtractData {
param (
Expand Down