$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."
}


Jayraj ChhayaRank #304 · 8.2K reputationPosted Mar 27, 2024, 5:11 AM EDT
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:
$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 'AccountAsyncPlugin' has been disabled." } else { Write-Host "Plugin 'AccountAsyncPlugin' not found." }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.Allam PurushothamRank #715 · 3.3K reputationPosted Apr 1, 2024, 12:33 AM EDT
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/