i want to write a ps script that will auto download exe file from suppliers site(e.g. http://www.suppliers.com/file.exe)
then after the download the scripts will check if existing file on local computer has already same file version with new download – if it is, scripts will not continue to run the exe and end the command
else – the file.exe will continue install and update the current installed application on local computer – then output reports to c:\file.log
what i have done so far is below and im not positive after this
ps(New-Object System.Net.WebClient).DownloadFile("www.suppliers.com/file.exe","C:\support\file.exe")& 'C:\support.exe' /q
(Get-Command "C:\Program Files (x86)\Uni\Bin\Uni.exe").FileVersionInfo.Fileversion
Well you've written out the steps you'd follow, but your script snippet doesn't follow your own steps...
Personally I would use Get-Item, not Get-Command, as Get-Command is really for looking at commands, modules and similar that are available in the PowerShell console. Get-Item is used to get information about a file. The command does work though.
Anyway, I would follow your own steps. So what you need to do is get the version of the existing file into one variable and then get the version of the newly downloaded file into another variable and then compare them.
If that comparison shows a difference, then run the setup file.
Post back with any further questions if you're still having trouble.
Powered by IDERA