Answered by:
update by date (and / or size) files from the http / https source

Question
-
windows 7 x64, powershell 5.1 (2-5.1).
need to check the address list (inserted it into the .ps1 code or read from the file) with local files by creation time, in case the local file is outdated, need to download a new one and replace old.
address list:
http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip http://download.geo.drweb.com/pub/drweb/tools/dwsysinfo.exe http://download.geo.drweb.com/pub/drweb/tools/drw_remover.exe https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player.exe http://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/Shockwave_Installer_Full.exe http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/sw_lic_full_installer.exe http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/sw_lic_full_installer.msi http://fpdownload.macromedia.com/get/shockwave/uninstall/win/sw_uninstaller.exe http://get.skype.com/go/getskype http://www.skype.com/go/getskype-full-last http://download.cdn.viber.com/desktop/windows/ViberSetup.exe http://download.cdn.oovoo.com/download/oovoosetup.msi http://www.nch.com.au/components/talksetup.exe http://download.eset.com/download/win/ess/ess_nt32_rus.exe http://download.eset.com/download/win/ess/ess_nt64_rus.exe https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt32_rus.exe https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt64_rus.exe http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.tar.gz http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/testing/current/firmware.zip
the second step: copying only the updated files to a shared folder. implemented in cmd as follows:
XCOPY %~dp0putty* \\192.168.1.1\setup\Putty\putty* /R /Y /D XCOPY %~dp0Skype* \\192.168.1.1\setup\Skype\Skype* /R /Y /D XCOPY %~dp0Viber* \\192.168.1.1\setup\Skype\Viber* /R /Y /D XCOPY %~dp0*flash_player* \\192.168.1.1\setup\_Adobe\*flash_player* /R /Y /D XCOPY %~dp0sw_lic_full_installer.* \\192.168.1.1\setup\_Adobe\sw_lic_full_installer.* /R /Y /D XCOPY %~dp0Shockwave_Installer_Full.exe \\192.168.1.1\setup\_Adobe\Shockwave_Installer_Full.exe /R /Y /D XCOPY %~dp0AdobeAIRInstaller.exe \\192.168.1.1\setup\_Adobe\AdobeAIRInstaller.exe /R /Y /D
thank youThursday, October 12, 2017 7:44 AM
Answers
-
update.ps1.cmd
powershell %~dp0update.ps1 XCOPY %~dp0putty* \\192.168.1.1\setup\Putty\putty* /R /Y /D XCOPY %~dp0Skype* \\192.168.1.1\setup\Skype\Skype* /R /Y /D XCOPY %~dp0Viber* \\192.168.1.1\setup\Skype\Viber* /R /Y /D XCOPY %~dp0*flash_player* \\192.168.1.1\setup\_Adobe\*flash_player* /R /Y /D XCOPY %~dp0sw_lic_full_installer.* \\192.168.1.1\setup\_Adobe\sw_lic_full_installer.* /R /Y /D XCOPY %~dp0Shockwave_Installer_Full.exe \\192.168.1.1\setup\_Adobe\Shockwave_Installer_Full.exe /R /Y /D XCOPY %~dp0AdobeAIRInstaller.exe \\192.168.1.1\setup\_Adobe\AdobeAIRInstaller.exe /R /Y /D pause
update.ps1
$web = [System.Net.HttpWebRequest]::Create("http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip") $r = $web.GetResponse() if((gi .\kavremvr.zip).LastWriteTime-ne $r.LastModified){ Invoke-WebRequest "http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip" -OutFile ".\kavremvr.zip" (gi .\kavremvr.zip).LastWriteTime = $r.LastModified } $h = @{ "http://download.geo.drweb.com/pub/drweb/tools/dwsysinfo.exe" = ".\dwsysinfo.exe" "http://download.geo.drweb.com/pub/drweb/tools/drw_remover.exe" = ".\drw_remover.exe" "https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe" = ".\putty.exe" "https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe" = ".\puttygen.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe" = ".\install_flash_player.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe" = ".\install_flash_player_ax.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe" = ".\install_flash_player_ppapi.exe" "https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player.exe" = ".\uninstall_flash_player.exe" "http://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe" = ".\AdobeAIRInstaller.exe" "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/Shockwave_Installer_Full.exe" = ".\Shockwave_Installer_Full.exe" "http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/sw_lic_full_installer.exe" = ".\sw_lic_full_installer.exe" "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/sw_lic_full_installer.msi" = ".\sw_lic_full_installer.msi" "http://fpdownload.macromedia.com/get/shockwave/uninstall/win/sw_uninstaller.exe" = ".\sw_uninstaller.exe" "http://get.skype.com/go/getskype" = ".\SkypeSetup.exe" "http://www.skype.com/go/getskype-full-last" = ".\SkypeSetupFull.exe" "http://download.cdn.viber.com/desktop/windows/ViberSetup.exe" = ".\ViberSetup.exe" "http://download.cdn.oovoo.com/download/oovoosetup.msi" = ".\oovoosetup.msi" "http://www.nch.com.au/components/talksetup.exe" = ".\talksetup.exe" "http://download.eset.com/download/win/ess/ess_nt32_rus.exe" = ".\ess_nt32_rus.exe" "http://download.eset.com/download/win/ess/ess_nt64_rus.exe" = ".\ess_nt64_rus.exe" "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt32_rus.exe" = ".\eis_nt32_rus.exe" "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt64_rus.exe" = ".\eis_nt64_rus.exe" "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.tar.gz" = ".\firmware.tar.gz" "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/testing/current/firmware.zip" = ".\firmware.zip" } foreach($i in $h.GetEnumerator()) { $file = Get-Item $i.Value $h = Invoke-WebRequest $i.Name -Method Head if($file.LastWriteTime -ne $h.Headers["Last-Modified"]){ Invoke-WebRequest $i.Name -OutFile $i.Value $file = Get-Item $i.Value $file.LastWriteTime = [datetime]$h.Headers["Last-Modified"] } }
thanks toKazun
https://kazunposh.wordpress.com/
https://social.technet.microsoft.com/profile/kazun/?ws=usercard-mini
Friday, October 13, 2017 10:44 AM
All replies
-
To compare files you first have to download all web files to a folder.
In Powersehll use [System.net.WebClient]::DowbloadFile($url, $destination)
Please read this first: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/c47b1bc2-f7fd-4d2e-8ff2-e8a81ce090d4/this-forum-is-for-scripting-questions-rather-than-script-requests?forum=ITCG
Also find scripts here: http://gallery.technet.microsoft.com/
Learn PowerShell: https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276
Script requests: https://gallery.technet.microsoft.com/scriptcenter/site/requests
\_(ツ)_/
Thursday, October 12, 2017 8:09 AM -
i know about downloading. i want to implement through checking the date of the file before uploading. that would not create an unnecessary download of the channel. there is a solution through wget, but more confidence in the built-in tools.
%~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.geo.drweb.com/pub/drweb/tools/dwsysinfo.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.geo.drweb.com/pub/drweb/tools/drw_remover.exe" %~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe" %~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe" %~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player.exe" %~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/Shockwave_Installer_Full.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/sw_lic_full_installer.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/sw_lic_full_installer.msi" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://fpdownload.macromedia.com/get/shockwave/uninstall/win/sw_uninstaller.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://get.skype.com/go/getskype" %~dp0wget.exe --no-check-certificate --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://www.skype.com/go/getskype-full-last" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.cdn.viber.com/desktop/windows/ViberSetup.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.cdn.oovoo.com/download/oovoosetup.msi" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://www.nch.com.au/components/talksetup.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.eset.com/download/win/ess/ess_nt32_rus.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://download.eset.com/download/win/ess/ess_nt64_rus.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt32_rus.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt64_rus.exe" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.tar.gz" %~dp0wget.exe --no-cache --no-dns-cache --continue --timestamping --tries=5 --timeout=0 "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/testing/current/firmware.zip" XCOPY %~dp0putty* \\192.168.1.1\setup\Putty\putty* /R /Y /D XCOPY %~dp0Skype* \\192.168.1.1\setup\Skype\Skype* /R /Y /D XCOPY %~dp0Viber* \\192.168.1.1\setup\Skype\Viber* /R /Y /D XCOPY %~dp0*flash_player* \\192.168.1.1\setup\_Adobe\*flash_player* /R /Y /D XCOPY %~dp0sw_lic_full_installer.* \\192.168.1.1\setup\_Adobe\sw_lic_full_installer.* /R /Y /D XCOPY %~dp0Shockwave_Installer_Full.exe \\192.168.1.1\setup\_Adobe\Shockwave_Installer_Full.exe /R /Y /D XCOPY %~dp0AdobeAIRInstaller.exe \\192.168.1.1\setup\_Adobe\AdobeAIRInstaller.exe /R /Y /D pause
Thursday, October 12, 2017 9:01 AM -
You cannot check the date of a link on a web server.
\_(ツ)_/
Thursday, October 12, 2017 9:08 AM -
update.ps1.cmd
powershell %~dp0update.ps1 XCOPY %~dp0putty* \\192.168.1.1\setup\Putty\putty* /R /Y /D XCOPY %~dp0Skype* \\192.168.1.1\setup\Skype\Skype* /R /Y /D XCOPY %~dp0Viber* \\192.168.1.1\setup\Skype\Viber* /R /Y /D XCOPY %~dp0*flash_player* \\192.168.1.1\setup\_Adobe\*flash_player* /R /Y /D XCOPY %~dp0sw_lic_full_installer.* \\192.168.1.1\setup\_Adobe\sw_lic_full_installer.* /R /Y /D XCOPY %~dp0Shockwave_Installer_Full.exe \\192.168.1.1\setup\_Adobe\Shockwave_Installer_Full.exe /R /Y /D XCOPY %~dp0AdobeAIRInstaller.exe \\192.168.1.1\setup\_Adobe\AdobeAIRInstaller.exe /R /Y /D pause
update.ps1
$web = [System.Net.HttpWebRequest]::Create("http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip") $r = $web.GetResponse() if((gi .\kavremvr.zip).LastWriteTime-ne $r.LastModified){ Invoke-WebRequest "http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.zip" -OutFile ".\kavremvr.zip" (gi .\kavremvr.zip).LastWriteTime = $r.LastModified } $h = @{ "http://download.geo.drweb.com/pub/drweb/tools/dwsysinfo.exe" = ".\dwsysinfo.exe" "http://download.geo.drweb.com/pub/drweb/tools/drw_remover.exe" = ".\drw_remover.exe" "https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe" = ".\putty.exe" "https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe" = ".\puttygen.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe" = ".\install_flash_player.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe" = ".\install_flash_player_ax.exe" "http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe" = ".\install_flash_player_ppapi.exe" "https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player.exe" = ".\uninstall_flash_player.exe" "http://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe" = ".\AdobeAIRInstaller.exe" "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/Shockwave_Installer_Full.exe" = ".\Shockwave_Installer_Full.exe" "http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/sw_lic_full_installer.exe" = ".\sw_lic_full_installer.exe" "http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/sw_lic_full_installer.msi" = ".\sw_lic_full_installer.msi" "http://fpdownload.macromedia.com/get/shockwave/uninstall/win/sw_uninstaller.exe" = ".\sw_uninstaller.exe" "http://get.skype.com/go/getskype" = ".\SkypeSetup.exe" "http://www.skype.com/go/getskype-full-last" = ".\SkypeSetupFull.exe" "http://download.cdn.viber.com/desktop/windows/ViberSetup.exe" = ".\ViberSetup.exe" "http://download.cdn.oovoo.com/download/oovoosetup.msi" = ".\oovoosetup.msi" "http://www.nch.com.au/components/talksetup.exe" = ".\talksetup.exe" "http://download.eset.com/download/win/ess/ess_nt32_rus.exe" = ".\ess_nt32_rus.exe" "http://download.eset.com/download/win/ess/ess_nt64_rus.exe" = ".\ess_nt64_rus.exe" "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt32_rus.exe" = ".\eis_nt32_rus.exe" "https://download.eset.com/com/eset/apps/home/eis/windows/latest/eis_nt64_rus.exe" = ".\eis_nt64_rus.exe" "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.tar.gz" = ".\firmware.tar.gz" "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/testing/current/firmware.zip" = ".\firmware.zip" } foreach($i in $h.GetEnumerator()) { $file = Get-Item $i.Value $h = Invoke-WebRequest $i.Name -Method Head if($file.LastWriteTime -ne $h.Headers["Last-Modified"]){ Invoke-WebRequest $i.Name -OutFile $i.Value $file = Get-Item $i.Value $file.LastWriteTime = [datetime]$h.Headers["Last-Modified"] } }
thanks toKazun
https://kazunposh.wordpress.com/
https://social.technet.microsoft.com/profile/kazun/?ws=usercard-mini
Friday, October 13, 2017 10:44 AM