< Back
Remove-CrmRecord
Post
NAME Remove-CrmRecord
SYNOPSIS
Delete a CRM record by specifying EntityLogicalName and record's Id (guid)
SYNTAX
Remove-CrmRecord [-conn <CrmServiceClient>] [-CrmRecord] <PSObject> [<CommonParameters>]
Remove-CrmRecord [-conn <CrmServiceClient>] [-EntityLogicalName] <String> [-Id] <Guid> [<CommonParameters>]
DESCRIPTION
The Remove-CrmRecord cmdlet lets you delete a record of your CRM organization.
There are two ways to delete a record.
1. Pass EntityLogicalName and record's Id.
2. Get a record object by using Get-CrmRecord/Get-CrmRecords cmdlets, then pass it.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CrmRecord <PSObject>
A record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you don't
use EntityLogicalName/Id.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-EntityLogicalName <String>
A logicalname for an Entity to delete. i.e.)accout, contact, lead, etc..
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Id <Guid>
An Id (guid) of the record
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, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
-------------------------- Example 1 --------------------------
Remove-CrmRecord -conn $conn -EntityLogicalName account -Id 52a17637-5617-e511-80dc-c4346bc4fc6c
This example deletes an account record by using Id
-------------------------- Example 2 --------------------------
PS C:\\>$account = Get-CrmRecord account b202caab-6c16-e511-80d6-c4346bc43dc0 name
PS C:\\>$account
accountid_Property : [accountid, b202caab-6c16-e511-80d6-c4346bc43dc0]
accountid : b202caab-6c16-e511-80d6-c4346bc43dc0
original : {[name_Property, [name, Adventure Works (sample)]], [name, Adventure Works (sample)],
[accountid_Property, [accountid,
b202caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, b202caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
PS C:\\>Remove-CrmRecord $account
PS C:\\>Get-CrmRecord account b202caab-6c16-e511-80d6-c4346bc43dc0 name
WARNING: Record Id: b202caab-6c16-e511-80d6-c4346bc43dc0Does Not Exist
This example retrieves and store an account record to $account object, then pass it to Remove-CrmRecord cmdlet.
Finally retrieves it again to confirm it is deleted.
When ommiting parameter names, you do not provide $conn, cmdlets automatically finds it.
-------------------------- Example 3 --------------------------
This example retrieves and stores account records by using FetchXML and pipe results (CrmRecords). In the next
pipe, it updates each record using Remove-CrmRecord.
Finally retrieves them again to confirm all records are deleted.
PS C:\\>$fetch = @"
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" no-lock="true">
<entity name="account">
<attribute name="name" />
</entity>
</fetch>
"@
PS C:\\>(Get-CrmRecordsByFetch $fetch).CrmRecords | % { Remove-CrmRecord $conn -CrmRecord $_}
PS C:\\>Get-CrmRecordsByFetch $fetch
WARNING: No Result
RELATED LINKS
SYNOPSIS
Delete a CRM record by specifying EntityLogicalName and record's Id (guid)
SYNTAX
Remove-CrmRecord [-conn <CrmServiceClient>] [-CrmRecord] <PSObject> [<CommonParameters>]
Remove-CrmRecord [-conn <CrmServiceClient>] [-EntityLogicalName] <String> [-Id] <Guid> [<CommonParameters>]
DESCRIPTION
The Remove-CrmRecord cmdlet lets you delete a record of your CRM organization.
There are two ways to delete a record.
1. Pass EntityLogicalName and record's Id.
2. Get a record object by using Get-CrmRecord/Get-CrmRecords cmdlets, then pass it.
PARAMETERS
-conn <CrmServiceClient>
A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CrmRecord <PSObject>
A record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you don't
use EntityLogicalName/Id.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-EntityLogicalName <String>
A logicalname for an Entity to delete. i.e.)accout, contact, lead, etc..
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Id <Guid>
An Id (guid) of the record
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, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
-------------------------- Example 1 --------------------------
Remove-CrmRecord -conn $conn -EntityLogicalName account -Id 52a17637-5617-e511-80dc-c4346bc4fc6c
This example deletes an account record by using Id
-------------------------- Example 2 --------------------------
PS C:\\>$account = Get-CrmRecord account b202caab-6c16-e511-80d6-c4346bc43dc0 name
PS C:\\>$account
accountid_Property : [accountid, b202caab-6c16-e511-80d6-c4346bc43dc0]
accountid : b202caab-6c16-e511-80d6-c4346bc43dc0
original : {[name_Property, [name, Adventure Works (sample)]], [name, Adventure Works (sample)],
[accountid_Property, [accountid,
b202caab-6c16-e511-80d6-c4346bc43dc0]], [accountid, b202caab-6c16-e511-80d6-c4346bc43dc0]}
logicalname : account
PS C:\\>Remove-CrmRecord $account
PS C:\\>Get-CrmRecord account b202caab-6c16-e511-80d6-c4346bc43dc0 name
WARNING: Record Id: b202caab-6c16-e511-80d6-c4346bc43dc0Does Not Exist
This example retrieves and store an account record to $account object, then pass it to Remove-CrmRecord cmdlet.
Finally retrieves it again to confirm it is deleted.
When ommiting parameter names, you do not provide $conn, cmdlets automatically finds it.
-------------------------- Example 3 --------------------------
This example retrieves and stores account records by using FetchXML and pipe results (CrmRecords). In the next
pipe, it updates each record using Remove-CrmRecord.
Finally retrieves them again to confirm all records are deleted.
PS C:\\>$fetch = @"
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" no-lock="true">
<entity name="account">
<attribute name="name" />
</entity>
</fetch>
"@
PS C:\\>(Get-CrmRecordsByFetch $fetch).CrmRecords | % { Remove-CrmRecord $conn -CrmRecord $_}
PS C:\\>Get-CrmRecordsByFetch $fetch
WARNING: No Result
RELATED LINKS