Skip to main content

PowershellScriptDeleteFile

All Cookstyle Cops


The department is: Chef/Correctness

The full name of the cop is: Chef/Correctness/PowershellScriptDeleteFile


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
Exclude
  • **/attributes/*.rb
  • **/metadata.rb
  • **/Berksfile
Array

Was this page helpful?









Search Results