PSSudo icon indicating copy to clipboard operation
PSSudo copied to clipboard

Can't use with Set-MpPreference?

Open vmiheer opened this issue 9 years ago • 3 comments

Set-MpPreference : Cannot process argument transformation on parameter 'DisableRealtimeMonitoring'. Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0. At line:1 char:45

  • Set-MpPreference -DisableRealtimeMonitoring False; pause
  •                                         ~~~~~
    
    • CategoryInfo : InvalidData: (:) [Set-MpPreference], ParameterBindingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-MpPreference

vmiheer avatar Oct 20 '16 06:10 vmiheer

Sorry I guess, you had already mentioned argument should be program and not commandLet. Should this be extended to take command blocks as argument?

vmiheer avatar Oct 20 '16 06:10 vmiheer

So, actually, I have implemented the ability for executing CmdLets on https://github.com/ecsousa/PSSudo/commit/5308514c7ee7ccebbf82357c51222a1e5613865b

But the problem is: when you execute:

sudo Set-MpPreference -DisableRealtimeMonitoring $False

I need to convert all parameters into string, in order to rewrite them as a command line argumento for a new PowerShell instance. In this scenario, $False get converto into the string 'False', which the new PowerShell instance is not able to implicit convert it back to a Boolean type.

I have to say I'm not entirely sure on how I would be able to get it working properly. I will try to think of something.

In the meantime, there is two work arounds that you can use:

sudo Set-MpPreference -DisableRealtimeMonitoring 0

or

sudo Set-MpPreference -DisableRealtimeMonitoring '$False'

I will also update README.md. I forgot to do so when I implemented support for CmdLets and .ps1 scripts.

ecsousa avatar Oct 20 '16 19:10 ecsousa

That workaround looks great. Thank you so much.

vmiheer avatar Oct 23 '16 18:10 vmiheer