class Chef::Resource::WindowsDefender

Constants

PROPERTY_TO_PS_MAP

Public Instance Methods

set_mppreference_cmd() click to toggle source
# File lib/chef/resource/windows_defender.rb, line 147
def set_mppreference_cmd
  cmd = "Set-MpPreference -Force"
  cmd << " -UILockdown #{type_coercion(new_resource.lock_ui)}"

  # the values are the opposite in Set-MpPreference and our properties so we have to iterate
  # over the list and negate the provided values so it makes sense with the cmdlet flag's expected value
  PROPERTY_TO_PS_MAP.each do |prop, flag|
    next if new_resource.send(prop).nil? || current_resource.send(prop) == new_resource.send(prop)

    cmd << " -#{flag} #{type_coercion(!new_resource.send(prop))}"
  end
  cmd
end