This project has moved. For the latest updates, please go here.

Get-CrmEntityKey

Synopsis

Get the Keys of an Entity

Syntax

Get-CrmEntityKey [-Entity] <String> [-Attributes <String[]>] [-Include <String>] [-Exclude <String>] [-ExcludeManaged] [<CommonParameters>]

Get-CrmEntityKey [-Id] <Guid> [<CommonParameters>]

Get-CrmEntityKey [-Entity] <String> [-Name] <String> [<CommonParameters>]

Description

Get the Keys of an Entity. The Attributes of the Keys uniquely identify the records of an Entity.

Parameters

-Entity <String>

Logicalname of the Entity to get the Keys for.

Required? True
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Attributes <String[]>

Find keys containing all the provided Attributes (by Logicalname)

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Include <String>

Filter for keys to include based on the logicalname of the key.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Exclude <String>

Filter for keys to exclude based on the logicalname of the key.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-ExcludeManaged <SwitchParameter>

Exclude managed keys.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Id <Guid>

The MetadataId of the key

Required? True
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Name <String>

The Logicalname of the key

Required? True
Position? 2
Default value  
Accept pipeline input? false
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, InformationAction, InformationVariable,
WarningAction, WarningVariable, OutBuffer, PipelineVariable and OutVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

Outputs

Microsoft.Xrm.Sdk.Metadata.EntityKeyMetadata

Notes

Available from Dynamics CRM 2015.1 and up

Examples

Get entity key

PS C:\> Get-CrmEntityKey -Entity account

Get all keys for Account

Get key by name

PS C:\> Get-CrmEntityKey -Entity account -Name ams_accountnumber

Get the key with logicalname 'ams_accountnumber' of the entity Account

Get key by attribute

PS C:\> Get-CrmEntityKey -Entity account -Attributes accountnumber -ExcludeManaged

Get keys from the entity Account where the key is unmanaged and contains the attribute 'accountnumber'.

Related links

EntityKeyMetadata Class https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.metadata.entitykeymetadata.aspx

Last edited Mar 11 at 7:03 PM by amsoftware, version 2