Skip to content

Commit

Permalink
Merge pull request WaelHamze#7 from ikurtev/master
Browse files Browse the repository at this point in the history
Add Verbose Switch for Get-CrmConnection and Update to Solution Import Result Validation
  • Loading branch information
WaelHamze authored Feb 22, 2017
2 parents af18784 + 2cd04d3 commit 05554b7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ $Cred = New-Object System.Management.Automation.PSCredential ($Username, $SecPas

switch($DeploymentType)
{
"Onpremises" { $CRMConn = Get-CrmConnection -ServerUrl $ServerUrl -OrganizationName $OrganizationName -Credential $Cred }
"Online" { $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion $DeploymentRegion –OnlineType $OnlineType –OrganizationName $OrganizationName }
"Onpremises" { $CRMConn = Get-CrmConnection -ServerUrl $ServerUrl -OrganizationName $OrganizationName -Credential $Cred -Verbose}
"Online" { $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion $DeploymentRegion –OnlineType $OnlineType –OrganizationName $OrganizationName -Verbose}
}

#Deploy Package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,38 @@ if ($override -or ($solution -eq $null) -or ($solution.Version -ne $solutionInfo
Write-Verbose "Import Error Text: $importErrorText"
Write-Verbose $importJob.Data

if (($importResult -ne "success") -or ($importProgress -ne 100))
if ($importResult -ne "success")
{
throw "Import Failed"
}

$solution = Get-XrmSolution -ConnectionString $CrmConnectionString -UniqueSolutionName $solutionInfo.UniqueName
#parse the importexportxml and look for result notes with result="failure"
$importFailed = $false
$importjobXml = [xml]$importJob.Data
$failureNodes = $importjobXml.SelectNodes("//*[@result='failure']")

if ($solution.Version -ne $solutionInfo.Version)
foreach ($failureNode in $failureNodes){
$componentName = $failureNode.ParentNode.Attributes['name'].Value
$errorText = $failureNode.Attributes['errortext'].Value
Write-Host "Component Import Failure: '$componentName' failed with error: '$errorText'"
$importFailed = $true
}

if ($importFailed -eq $true)
{
throw "The Solution Import failed because one or more components with a result of 'failure' were found. For detals, check the Diagnostics for this build or the solution import log file in the logs subfolder of the Drop folder."
}
else
{
Write-Host "The import result of all components is 'success'."
}
#end parse the importexportxml and look for result notes with result="failure"

$solution = Get-XrmSolution -ConnectionString $CrmConnectionString -UniqueSolutionName $solutionInfo.UniqueName

if ($solution.Version -ne $solutionInfo.Version)
{
throw "Import Failed"
throw "Import Failed. Check the solution import log file in the logs subfolder of the Drop folder."
}
else
{
Expand Down

0 comments on commit 05554b7

Please sign in to comment.