Activate & Deactivate Account Record in Dynamic 365 with PowerShell

Step 1.

$conn = Get-CrmConnection -InteractiveMode
$conn.BypassPluginExecution = $true
$conn = Get-CrmConnection

InteractiveMode: This command initiates an interactive session to prompt the user for login credentials and establish a connection to Dynamics CRM. Upon successful connection, the connection object is stored in the $conn variable.

$conn.BypassPluginExecution = $true

This line sets the BypassPluginExecution property of the $conn object to $true, indicating that plugin execution should be bypassed for operations performed through this connection.

Login

Starting login process

Step 2. Set-CrmRecordState -conn $conn -EntityLogicalName account -Id 63b5066c-cecf-ee11-904d-6045bdad183f -StateCode 1 -StatusCode 2

Account

Step 3. Set-CrmRecordState -conn $conn -EntityLogicalName account -Id 63b5066c-cecf-ee11-904d-6045bdad183f -StateCode 0 -StatusCode 1

Account information

Step 4. Set-CrmRecordState -conn $conn -EntityLogicalName account -Id 63b5066c-cecf-ee11-904d-6045bdad183f -StateCode Inactive -StatusCode Inactive

Summary

Step 5. Set-CrmRecordState -conn $conn -EntityLogicalName account -Id 63b5066c-cecf-ee11-904d-6045bdad183f -StateCode active -StatusCode active

Account


Similar Articles