How do I check if a folder exists in Chef?
This is my code: if !::File.exist?("#{node['iis']['home']}\\backup\\BkpB4Chef") windows_batch "Backup IIS Config" do code <<-EOH "#{node['iis']['home']}"\\appcmd add backup BkpB4Chef EOH end end It always says file exists and executes the loop. sethvargo You should use Chef guards here. Guards specify conditional execution, but still insert the resource into the resource collection. In your example and jtblin answer, the resource is never added to the collection (which I'll explain a bit further in a moment). Here's some working code to get you started: windows_batch "Backup IIS Config" do