diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.pshproj b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.pshproj index 2d60cf1..8f0b51c 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.pshproj +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.pshproj @@ -10501,6 +10501,61 @@ false + + New-CrmSolutionPatch + + New-CrmSolutionPatch [-conn <CrmServiceClient>] [-PatchName] <String> + + + Creates a new solution patch. + Creates a new empty patch by splitting on the period in the patch name to find the parent patch. It finds all versions of the parent patches and increments the highest build number x (1.2.x.0) by 1 and sets 0 as the revision. + + + + + + + + + + + + + + conn + + System.Management.Automation.ParameterAttribute + System.Management.Automation.ArgumentTypeConverterAttribute + + + + A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it. + + + + + PatchName + + System.Management.Automation.ParameterAttribute + System.Management.Automation.ArgumentTypeConverterAttribute + + + The display name of the patch to split and return the parent patch name + + + + + + Example 1 + New-CrmSolutionPatch -PatchName Customizations.123.PatchDescription + Creates a new solution patch against the Customizations solution + + + + + + false + Import-CrmSolutionAsync diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.xml b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.xml index d0add5c..4d9f30c 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.xml +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.Help.xml @@ -19689,6 +19689,127 @@ When omitting parameter names, you do not provide $conn, cmdlets automatically f + + + New-CrmSolutionPatch + + Creates a new solution patch. + + + + + New + CrmSolutionPatch + + + + Creates a new empty patch by splitting on the period in the patch name to find the parent patch. It finds all versions of the parent patches and increments the highest build number x (1.2.x.0) by 1 and sets 0 as the revision. + + + + New-CrmSolutionPatch + + conn + + A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it. + + + CrmServiceClient + + + PatchName + + The display name of the patch to split and return the parent patch name + + String + + + + + + conn + + A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it. + + + CrmServiceClient + + CrmServiceClient + + + + + + PatchName + + The display name of the patch to split and return the parent patch name + + String + + String + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + + PS C:\> + + New-CrmSolutionPatch -PatchName Customizations.123.PatchDescription + + Creates a new solution patch against the Customizations solution. + + + + + + + + + + + + + + + + + Grant-CrmRecordAccess diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 index 6f58a45..8d0de68 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 @@ -1928,6 +1928,57 @@ function Get-CrmEntityOptionSet{ return $result } +#NewCrmSolutionPatch +function New-CrmSolutionPatch { +# .ExternalHelp Microsoft.Xrm.Data.PowerShell.Help.xml + [CmdletBinding()] + PARAM ( + [parameter(Mandatory=$false)] + [Microsoft.Xrm.Tooling.Connector.CrmServiceClient]$conn, + [Parameter(Mandatory, Position=1)] + [ValidateNotNullOrEmpty()] + [string]$PatchName + ) + + BEGIN { + $conn = VerifyCrmConnectionParam -conn $conn -pipelineValue ($PSBoundParameters.ContainsKey('conn')) + } + + PROCESS { + + $parentSolution = $PatchName -split '\.' | Select-Object -First 1 + Write-Verbose "Detected parent solution as: $parentSolution" + + $solutions = Get-CrmRecords -conn $conn -EntityLogicalName solution -FilterAttribute friendlyname -FilterOperator "like" -FilterValue "$parentSolution%" -Fields solutionid,uniquename,friendlyname,version + Write-Verbose "Found $($solutions.CrmRecords.Count) solutions/patches for $parentSolution" + if ($solutions.CrmRecords.Count -ge 1) { + $minMax = $solutions.CrmRecords | % { [Version]$_.version } | Measure-Object -max -min + $v = [Version]$minMax.Maximum + $newVersion = [Version]::new($v.Major, $v.Minor, $v.Build+1, 0) + Write-Verbose "Current max version: $($minMax.Maximum)" + Write-Verbose "Using $newVersion for $PatchName" + + $patchDetails = @{ + ParentSolutionUniqueName = $parentSolution + DisplayName = $PatchName + VersionNumber = $newVersion.ToString() + } + Write-Verbose 'Creating patch ...' + $result = Invoke-CrmAction -conn $conn -Name CloneAsPatch -Parameters $patchDetails + + return $result + + } else { + + throw "No matching parent solutions found for $PatchName" + + } + + } + + END { } +} + #ImportSolutionToCrmAsync function Import-CrmSolutionAsync { # .ExternalHelp Microsoft.Xrm.Data.PowerShell.Help.xml