functions/Get-SolutionImportLog.ps1
Import-Module crm-datatools function Get-SolutionImportLog () { param( # Determines which CRM instance the solution will be imported to. Note that these are hard-coded - any changes will require changes to this script module's source code or it will break! [ValidateSet("CRMRECRUIT", "CRMRECRUITTEST", "CRMADVISE", "CRMADVISETEST")] [Parameter(Mandatory = $true)] $CrmInstance, # The GUID of the ImportJob. Should be returned by Import-CrmSolution [Parameter(Mandatory = $true)] [string]$ImportJobId, # An optional parameter specifying a path to save the xml log file. $ExportPath, # Credentials used to connect to the crm [pscredential]$Credential ) $orgURI = Get-CrmConnectionString -CrmInstance $CrmInstance -UrlOnly $api = $orgURI + "/api/data/v8.0" $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Accept", 'application/json') $headers.Add("Content-Type", 'application/json; charset=utf-8') $headers.Add("OData-MaxVersion", '4.0') $headers.Add("OData-Version", '4.0') $resp = Invoke-RestMethod ` -Method Get ` -Credential $Credential ` -Uri "$api/RetrieveFormattedImportJobResults(ImportJobId=$ImportJobId)" -Headers $headers if ($ExportPath) { $pathParent = Split-Path -Path $ExportPath -Parent if (-not (Test-Path $pathParent)) { New-Item $pathParent -ItemType Directory } $resp.FormattedResults > $ExportPath } return $resp.FormattedResults } |