Chef/Correctness/PowershellScriptDeleteFile
The Cookstyle cops department: Chef/Correctness
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 |