Skip to main content

Chef/Modernize/PowershellDownloadFile

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll Versions

Use the remote_file resource to download files instead of shelling out to PowerShell. remote_file is idempotent, supports checksum verification, proxies, and conditional downloads with etags and last-modified headers, none of which a script gets for free.

Examples

# bad
powershell_script 'download the installer' do
  code 'Invoke-WebRequest -Uri https://example.com/foo.msi -OutFile C:\foo.msi'
end

# good
remote_file 'C:\foo.msi' do
  source 'https://example.com/foo.msi'
end

Configurable attributes

NameDefault valueConfigurable values
Version Added9.0.0String
Include
    Array

    Thank you for your feedback!

    ×