Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Releases: AMSoftwareNL/crmpowershell

Dataverse Powershell Library v2.2.0.0

07 Nov 18:54
Compare
Choose a tag to compare

Issues & Changes

  • #37 Support Impersonation

  • #38 Deployment mandatory with Register-CrmPluginStep

  • #39 Add features for (Access) Teams

  • #40 Manage Roles and Privileges

  • #41 Add Application User

  • Update to latest supported framework and packages

    • Microsoft.CrmSdk.XrmTooling.CoreAssembly 9.1.0.92

Impersonation

Use Use-CrmImpersonatedUser or Set-CrmSession -ImpersonatedUserId to set the UserId of the user to impersonate. This update the session context connection and applies to all following requests. Set to Guid.Empty to stop the impersonation.

Using the commands sets both the CallerId for the OrganizationService as the CallerAADObjectId for the Web API.

Register-CrmPluginStep: Deployment parameter

The parameter Deployment was mandatory on Register-CrmPluginStep. This is changed to optional with the default value Both, as this is the value most will use.

Teams features

New and updated Cmdlets to support the latest Dataverse feature for Teams. This includes manage Team Templates, manage Azure AD connected Teams, and add and remove users for record Teams.

New and Updated Cmdlets are:

  • New-CrmTeam
  • Remove-CrmTeam
  • Set-CrmTeam
  • Get-CrmTeamTemplate
  • New-CrmTeamTemplate
  • Remove-CrmTeamTemplate
  • Set-CrmTeamTemplate
  • Add-CrmRecordTeamUser
  • Remove-CrmRecordTeamUser

Security & Privileges

The library now has support to manage security and privileges with the following Cmdlets:

  • Get-CrmContentAccess
  • Get-CrmPrincipalPrivileges
  • Get-CrmRolePrivileges
  • Remove-CrmRolePrivilege
  • Set-CrmRole
  • Set-CrmRolePrivilege
  • Test-CrmUserPrivilege

The New-CrmRole and Set-CrmRole Cmdlets also have the Inheritance parameter.

Application User

And last but not least the New-CrmApplication cmdlet is added to add an Azure App Registration (SPN) as Application User in Dataverse. All you have to provide is the AppId/ClientId.

Dataverse Powershell Library v2.1.1.0

06 Aug 13:06
Compare
Choose a tag to compare

Issues & Changes

  • #26 Support Batch operations

  • #28 Get and Set Environment Variables

  • #30 Service Endpoint doesn't support Webhook and EventHub

  • #31 Support for Virtual Entities and custom data-sources

  • #33 Provide clear error info when connection fails (see also #32)

  • #34 Support new multi-table lookup

  • #35 Support Upsert

  • Update to latest supported framework and packages

    • Microsoft.CrmSdk.XrmTooling.CoreAssembly 9.1.0.79

Polymorphic (Multi Table) Lookup

Add a Polymorphic Lookup the same way a normal lookup is added, just add the switch Polymorphic. Add one single relationship at a time. When the relationship/lookup is marked as Polymorphic The Lookup and Relationship are created if the Attribute doesn't exist. Else the Relationships is added to the exiting Lookup. In this case additional Attribute parameters are ignored.

Microsoft documentation: Use multi-table lookup columns

Add-CrmRelationship -Entity 'new_media' -ToEntity 'new_books' -Name 'new_media_books' -Polymorphic -AttributeName 'new_contentid' -AttributeDisplayName 'Content'
Add-CrmRelationship -Entity 'new_media' -ToEntity 'new_audio' -Name 'new_media_audio' -Polymorphic -AttributeName 'new_contentid' -AttributeDisplayName 'Content' -
Add-CrmRelationship -Entity 'new_media' -ToEntity 'new_video' -Name 'new_media_video' -Polymorphic -AttributeName 'new_contentid' -AttributeDisplayName 'Content'

Data Providers, Data Sources and Virtual Tables

Register Data Providers, and create Data Source Tables and Virtual Tables.

Microsoft documentation: Get started with virtual tables

$publisher = New-CrmPublisher -Name 'amsoftware_test' -DisplayName 'AMSoftware (Test)' -Prefix 'ams' -PassThru
$solution = New-CrmSolution -Name 'ams_virtual_data' -DisplayName 'Virtual Data' -Version '1.0.0.0' -Publisher $publisher -PassThru
Use-CrmSolution $solution

$plugin = Register-CrmPlugin -LiteralPath '.\DSPlugin.dll' -IsolationMode Sandbox -AssemblyLocation Database -PassThru

# Create the Data Source Virtual Table to hold the actual Data Sources (configurations)
New-CrmEntity -DataSource -Name 'ams_rssfeed' -DisplayName 'RSS Feed Data Source' -DisplayCollectionName 'RSS Feed Data Sources' -AttributeName 'ams_name' -AttributeDisplayName 'Name' -AttributeExternalName 'name' -AttributeRequired Required -PassThru
Add-CrmStringAttribute -Entity 'ams_rssfeed' -Name 'ams_feeduri' -Format Url -Length 250 -DisplayName 'Feed URI' -Required Required -ExternalName 'feeduri'
Add-CrmStringAttribute -Entity 'ams_rssfeed' -Name 'ams_feedkey' -Format Url -Length 25 -DisplayName 'Feed Key' -Required Required -ExternalName 'feedkey' -IsDataSourceSecret

# Add a Data Source Configuration. The ID is needed for creation of the Virtual Table
$feedconfig = Add-CrmContent -Entity 'ams_rssfeed' -Attributes @{ams_name='Microsoft Power Platform Blog';ams_feeduri='https://cloudblogs.microsoft.com/powerplatform/feed/';ams_feedkey='secret'} -PassThru

# Register the Data Provider with the Data Source
$dataprovider = Register-CrmDataProvider -Name 'RSS Feed Data Provider' -DataSourceLogicalName 'ams_rssfeed' -RetrievePlugin $plugin -RetrieveMultiplePlugin $plugin -CreatePlugin $plugin -UpdatePlugin $plugin -DeletePlugin $plugin -PassThru

# Create the Virtual Table to hold the 'Microsoft Power Platform Blog' feed
New-CrmEntity -Virtual -Name 'ams_powerplatformblogfeed' -DisplayName 'Microsoft Power Platform Blog' -DisplayCollectionName 'Microsoft Power Platform Blogs' -ExternalName 'powerplatformblogfeed' -ExternalCollectionName 'powerplatformblogfeeds' -DataSourceConfiguration $feedconfig.ToEntityReference() -AttributeName 'ams_title' -AttributeDisplayName 'Title' -AttributeExternalName 'title' -AttributeRequired Required -AttributeLength 255 -HasNotes $true

Environment Variables

Define Environment Variables and set the Value.

Microsoft documentation: Environment variables overview

Service Endpoints, Webhooks and EventHub

Registration of Service Endpoints is updated to the latest configuration options, and now also supports registration for Azure EventHub.

The registration of WebHooks is added using Register_CrmWebHook

Microsoft Documentation:
Use WebHooks to create external handlers for server events
Work with Microsoft Dataverse event data in your Azure Event Hub solution

Upsert instead of just Add

On Add-Content include the Upsert switch to perform an Upsert instead of an Add.

Microsoft documentation: Use Upsert to insert or update a record

Batch support

For the more exotic scenarios simple batched operations can now be performed based on the ExecuteMultiple request and the ExecuteTransaction request. Only a simple batch is a supported. No nesting or multiple transaction, and the whole batch is a transaction or not.

Only the default content cmdlets can be include in a batch by adding the AsBatch switch.

  • Add-CrmContent
  • Get-CrmContent
  • Join-CrmContent
  • Remove-CrmContent
  • Set-CrmContent
  • Split-CrmContent
  • Invoke-CrmRequest
Start-CrmBatch
Add-CrmContent -Entity 'account' -Attributes @{name='Account 1'} -AsBatch
Add-CrmContent -Entity 'account' -Attributes @{name='Account 2'} -AsBatch
Add-CrmContent -Entity 'account' -Attributes @{name='Account 3'} -AsBatch
Add-CrmContent -Entity 'account' -Attributes @{name='Account 4'} -AsBatch
Submit-CrmBatch -AsTransaction -ReturnResponses

Retrieve Data Performance

There was a major issue with the performance when getting data. Getting 50 rows of data took almost 30 seconds. This was due to a major issue in the EntityPropertyAdapter. This adapter does the flattening/pivoting of the Attributes-collection and FormattedValues-collection. For every row multiple calls to the Entity- and Attribute-metadata were performed. This is now solved by getting the metadata for the Entity and Attributes once and using this.
In addition the Metadata-cache was checked on every call to metadata. Now the cache is checked (and updated if needed) at the start of every cmdlet (in the BeginProcessing function), so during execution of the cmdlet the up-to-date cache is used, and no longer being checked or updated.

Fixes, Optimizations and Performance improvements

  • Dynamic Parameters merged with normal cmdlet logic
    No more use of Dynamic Parameters based on versions as this wasn't updated since Dynamics 2016. Dynamic Parameters were also not included in the docs. Now the docs are complete.
  • Removed VersionChecks
    Version checks on cmdlets and parameters are removed. Every cmdlet is now always up-to-date with the latest version of Dataverse. It's up to the user to skip non supported cmdlets and parameters if using the library on-premises.
  • Fix on Get-CrmEntityKey
    The Attributes parameter contained an incorrect ArgumentCompleter
  • Use PSBoundParameters to check provided values
    Instead of using Nullable types and values to check if a parameter and value are provided, now we use the PSBoundParameters. As a result parameters are now no longer Nullable. If provided the values are used as-is.
  • Optimized cache use
    Metadata cache is now used with all Entity related metadata cmdlets.
    Cache initialization can be forced on Connect-CrmOrganization using the InitializeMetadataCache switch. Otherwise the cached is initialized on first use.
  • Get-CrmEntity with EntityTypeCode
  • OrganizationRequest and -Response PropertyAdapters to flatten/pivot the Parameters and Results, like with Entity Attributes.

Dataverse Powershell Library v2.1.0.0

08 Aug 12:10
Compare
Choose a tag to compare

This release is pulled in favor of v2.1.1.0 as it contained an issue with the LogicalName and Id fields for records.
see also: #36

Dataverse Powershell Library v2.1.1.0

CRM Powershell Library v2.0.0.0

28 Mar 09:37
Compare
Choose a tag to compare

Issues & Changes

  • #24 Use Xrm.Tooling.CrmConnector from the SDK or the Powershell cmdlet to connect to Dynamics/Dataverse

  • #27 Mandatory OAuth2.0

  • #23 New-Command Get-CrmSPDocumentLocation (thanks to @RichieRoxx)

  • #25 Add Invoke-CrmWebApiRequest

  • Update to latest supported framework and packages

    • .NET Framework 4.6.2
    • Microsoft.CrmSdk.XrmTooling.CoreAssembly 9.1.0.68 including Microsoft.CrmSdk.CoreAssemblies 9.0.2.25

Modern Authentication

To support changes to the login and authentication of modern Power Platform Dataverse environements and Dynamics 365 environments (on-premises and online) the classic authentication mechanism (WS-Trust) is removed, and instead the connection is to an environment is based on CrmServiceClient.

This is not implemented in the module, but instead the module Microsoft.Xrm.Tooling.CrmConnector.PowerShell is utilized.

Connect via CrmServiceClient

Install-Module 'Microsoft.Xrm.Tooling.CrmConnector.PowerShell'
$connection = Get-CrmConnection -InteractiveMode
Connect-CrmOrganization -Connection $connection

Connect via Connectionstring

Connect-CrmOrganization -Connectionstring 'AuthType=Office365;[email protected];Password=passcode;Url=https://contoso.crm.dynamics.com'

CRM Powershell Library v1.4.1.0

01 Dec 17:09
Compare
Choose a tag to compare

Issues & Changes

Fixed issue:

  • #18 Set new attributes to in-memory entity not possible
  • #19 FetchXml with aggregate fails on PagingCookie
  • #22 FetchXML with aggregate executes as query without aggregate

New features:

  • #20 IntelliSense on Entities, Attributes and other Metadata
  • #21 Support for collections from pipeline

CRM Powershell Library v1.4.0.1

13 Sep 21:59
Compare
Choose a tag to compare

Issues & Changes

  • Fixed issue: #17

CRM Powershell Library v1.4.0.0

18 Jun 21:35
Compare
Choose a tag to compare

General

To prevent issues with loading module the DefaultPrefix for Cmdlets is removed from the ModuleDefinition (.psd1). Prefix is now hard-coded in the name of the Cmdlets. Same as Microsoft does. See #6 .

Cmdlets

From issue #15

  • Remove-CrmPrincipalRoles
  • Remove-CrmRolePrincipals
  • Remove-CrmTeamUsers
  • Remove-CrmUserTeams

Issues & Changes

CRM Powershell Library v1.3.1.2

13 Apr 17:26
Compare
Choose a tag to compare

CRM Powershell Library v1.3.1.1

13 Feb 00:53
Compare
Choose a tag to compare

NOTE: The code signing certificate is expired, so this release is not code signed.

Cmdlets

  • Import-CrmSolution

Issues & Changes

  • Added Async parameter to Import-CrmSolution
  • Fixed issue #3, #4 and #5
    NOTE: String compare on displayname and other labels will not work, but at least won't give an error.

CRM Powershell Library v1.3.0.0

03 Nov 19:30
Compare
Choose a tag to compare

NOTE: This release contains breaking changes from previous versions. Be sure to test your scripts before updating.

Cmdlets

All Cmdlets are impacted by the changes made in this release. See 'Issues & Changes'.

Issues & Changes

  • Combined 'Name' and 'Include' parameters.
    The separate parameters Name (without wildcard support) and Include (with wildcard support) are combined as the parameter Name with wildcard support. Include can still be used as the alias.
  • Improved pipeline support.
    Cmdlets which require parent information to function now support this parent information from the pipeline.
    The following are now supported for example:
    Get-CrmEntity account | Get-CrmAttribute
    Get-CrmSolution mysolution | Get-CrmSolutionComponent
  • Default sorting on Metadata cmdlet output.
    Sorting is applied to the output of Cmdlets which return CRM Metadata; like Get-CrmEntity and Get-CrmAttribute.
  • Default sorting on administration & customization cmdlet output.
    Sorting is applied to the output of Cmdlets which return CRM administration or customization information; like Get-CrmUser and Get-CrmPublisher.
  • Consistent use of 'InputObject' parameter, conform to best practices for PowerShell.
    All Cmdlets which could receive a complex object as input now consistently use InputObject as the parameter. The previous names of the parameters are still available as alias.
  • 'PassThru' parameter on all Cmdlets with optional output.
    All Cmdlets (except Get-Crm...) have the PassThru parameter. This needs to be provided to get an output from the cmdlets. By default none return a result. This means New-CrmEntity will not return the EntityMetadata unless explicitly specified with PassThru.
  • Exporting Cmdlet output contains object values, instead of object Types.
    This required a major rewrite and addition of PSPropertyAdapters. The result is all object properties are exposed as their true type, but complex types are wrapped in a custom PSObject which overrides ToString().
    As a result all properties can be used as their true Types, but will return a readable value to output. This output included Export-Csv for example.
  • Clear distinction between default properties and extended properties.
    The postfixes for extended properties are clearly recognizable. '_FormattedValue' for values from the FormattedValue collection and '_Entity' for the LogicalName of an EntityReference.
  • Removed 'RelatedEntities' from Get-CrmContent.
    The option to include related entities in Get-CrmContent is removed.