Skip to main content

Chef/Correctness/PowershellScriptDeleteFile

Cookstyle cops page

The Cookstyle cops department: Chef/Correctness

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll Versions

Use the file or directory resources built into Chef Infra Client with the :delete action to remove files/directories instead of using Remove-Item in a powershell_script resource

correct

file ‘C:\Windows\foo\bar.txt’ do action :delete end

Examples

incorrect

powershell_script 'Cleanup old files' do
  code 'Remove-Item C:\Windows\foo\bar.txt'
  only_if { ::File.exist?('C:\\Windows\\foo\\bar.txt') }
end

Configurable attributes

NameDefault valueConfigurable values
Version Added6.0.0String
Include
    Array

    Thank you for your feedback!

    ×









    Search Results