Skip to main content

PowershellScriptDeleteFile

The department is: PowershellScriptDeleteFile

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

Enabled by default Supports autocorrection Target Chef Version
Enabled No All 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

Name Default value Configurable values
Version Added 6.0.0 String
Include
Array

Was this page helpful?

×









Search Results