$plugins = Get-CrmPlugin -Connection $crmConnection
$pluginToDisable = $plugins | Where-Object { $_.Name -eq "AccountAsyncPlugin" }
# Check if the plugin was found
if ($pluginToDisable) {
# Disable the plugin
Disable-CrmPlugin -Connection $crmConnection -Id $pluginToDisable.Id
Write-Host "Plugin 'MyPlugin' has been disabled."
} else {
Write-Host "Plugin 'MyPlugin' not found."
}

Allam PurushothamPosted Apr 1, 2024, 4:33 AM
To disable/enable plugin step please follow below link:
https://www.c-sharpcorner.com/article/how-to-enable-and-disable-plugin-in-d365-using-power-shell-script/
Jayraj ChhayaPosted Mar 27, 2024, 9:11 AM
Hi ,
Problem
The current script is attempting to disable a plugin named "AccountAsyncPlugin" but references a plugin named "MyPlugin" in the output message. This inconsistency could lead to confusion and miscommunication.
Cause
The bug in the script lies in the output message after attempting to disable the plugin. The script incorrectly references "MyPlugin" instead of the actual plugin name, "AccountAsyncPlugin."
Solution
To disable a plugin in Dynamics CRM using PowerShell, you can follow these steps:
In the provided PowerShell script, the plugin named "AccountAsyncPlugin" is being disabled. The script first retrieves all plugins using
Get-CrmPlugin, then filters the specific plugin to disable. If the plugin is found, it is disabled usingDisable-CrmPlugin. Finally, appropriate messages are displayed based on whether the plugin was found and disabled or not.