summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-06-06 21:18:20 -0700
committerTim Smith <tsmith@chef.io>2021-06-06 21:18:20 -0700
commiteba8d791babb89c04a455cf1520532d9b86fb767 (patch)
tree8cba5151612e58467eabdf2771cf7626fc17866c /lib/chef
parent0a53ac4b3b592634141ea563f3a41b6fdd7b332d (diff)
downloadchef-eba8d791babb89c04a455cf1520532d9b86fb767.tar.gz
Delete with a PowerShell Cmdlet
This is much simpler Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/resource/windows_printer.rb13
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb
index 6f62c5deb7..b1d6e29374 100644
--- a/lib/chef/resource/windows_printer.rb
+++ b/lib/chef/resource/windows_printer.rb
@@ -103,11 +103,11 @@ class Chef
action :delete, description: "Delete an existing printer. Note that this resource does not delete the associated printer port." do
if printer_exists?
- converge_by("Delete #{@new_resource}") do
- delete_printer
+ converge_by("Delete #{new_resource.device_id}") do
+ powershell_exec!("Remove-Printer -Name '#{new_resource.device_id}'")
end
else
- Chef::Log.info "#{@current_resource} doesn't exist - can't delete."
+ Chef::Log.info "#{new_resource.device_id} doesn't exist - can't delete."
end
end
@@ -145,13 +145,6 @@ class Chef
EOH
end
end
-
- def delete_printer
- powershell_exec! <<-EOH
- $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.device_id}'"
- $printer.Delete()
- EOH
- end
end
end
end