Last active
August 29, 2015 14:04
-
-
Save Phelms215/a29d9e0ac797439f98bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if !File.exist?('C://chef//cache//WUInstall.ps1') | |
cookbook_file "WUInstall.ps1" do | |
source "WUInstall.ps1" | |
backup false | |
inherits true | |
action :create_if_missing # Not always working - throws error randomly if file exists | |
path 'C:\\Windows\\SoftwareDistribution\\WUInstall.ps1' | |
end #end cookbook_file | |
end #end File.exist | |
updateList = node["UPDATES"] | |
updateList.each_with_index do |x,key| | |
updateTime = Time.at( x["Time"].to_i / 1000 ) | |
t1 = Time.now | |
now = Time.at(t1.to_i) | |
powershell_script '#{x["KB"]}_DOWNLOAD' do | |
#not_if { now < updateTime } | |
code <<-EOH | |
."C:\\Windows\\SoftwareDistribution\\WUInstall.ps1" | |
Get-WUInstall -UpdateType "Software" -KBArticleID KB#{x["KB"]} -DownloadOnly | Out-File C:\\chef\\update.log | |
EOH | |
end #end of powershell_script | |
end #end of each_with_index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment