Add-MpPreference is not recognized as a name
powershell
Solution
I had a similar issue. I discovered that when running Powershell in 32 bit mode on a 64 bit OS it doesn't find the command Add-MpPreference.
You can easily recreate this by opening a Powershell console in 32 bit mode and call this function. It will give the same error.
The issue occurred because I was running the Powershell script from C# code that was running as 32 bit. This caused the powershell.exe that was called to also be the 32 bit version.
I adjusted the code to call the 64 bit version and then the command was found.
In order to do this have it run Powershell from here C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe
For more information about how to set the version of powershell visit https://web.archive.org/web/20180314210451/http://www.madwithpowershell.com/2015/06/64-bit-vs-32-bit-powershell.html
Problem
Hello i am doing a small script will run a small powershell using `Add-MpPreference`. In my case, i was doing because sometimes i want to include some path's in my windows 10 but i must to do manually. So i was trying to make it automatic. I did this: ``` ShellExecute("powershell", '-noexit Add-MpPreference -ExclusionPath C:/') ``` Error return's me: ``` The term 'Add-MpPreference' is not recognized as the name of a cmdlet, function , script file, or operable program. Check the spelling of the name, or if a pat h was included, verify that the path is correct and try again. At line:1 char:17 + Add-MpPreference <<<< -ExclusionPath C:/ + CategoryInfo : ObjectNotFound: (Add-MpPreference:String) [], Co mmandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ``` What mean's this error? Or can be fixed?