diff options
author | Tim Smith <tsmith@chef.io> | 2019-01-16 10:56:06 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-01-16 10:56:06 -0800 |
commit | 59f7b45f6f408eef75c2e6625ce1171adf86e22c (patch) | |
tree | a1d227d18266eaceda4df6db330733957e87833c | |
parent | c86f10dfb9c898874a58cff92804ef437e3e8e98 (diff) | |
download | chef-59f7b45f6f408eef75c2e6625ce1171adf86e22c.tar.gz |
windows_printer: prevent failures when deleting printers and using device_id propertyprinter_delete
We have a name_property of device_id for this resource but we weren't using it in the delete_printer method so if you used the name property the deletion would fail.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/windows_printer.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb index 605b7b8521..8ddb085ee3 100644 --- a/lib/chef/resource/windows_printer.rb +++ b/lib/chef/resource/windows_printer.rb @@ -114,7 +114,7 @@ class Chef port_name = "IP_#{new_resource.ipv4_address}" - declare_resource(:powershell_script, "Creating printer: #{new_resource.name}") do + declare_resource(:powershell_script, "Creating printer: #{new_resource.device_id}") do code <<-EOH Set-WmiInstance -class Win32_Printer ` @@ -133,9 +133,9 @@ class Chef end def delete_printer - declare_resource(:powershell_script, "Deleting printer: #{new_resource.name}") do + declare_resource(:powershell_script, "Deleting printer: #{new_resource.device_id}") do code <<-EOH - $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.name}'" + $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.device_id}'" $printer.Delete() EOH end |