结合计划任务每天从Symantec官网下载离线病毒库

#三种方法,由初级到高级

$numbers
= 1..40 | Foreach {"{0:D3}" -f $_} #将数字类型格式化并转换为字符串类型使用-f字符串操作符 ForEach ($number in $numbers) { $Source = 'http://definitions.symantec.com/defs/' + ((Get-Date -Format yyyyMMdd) - 1) + '-' + $number + '-v5i32.exe' $Destination = "F:\" + ((Get-Date -Format yyyyMMdd) - 1) + "-" + $number + ".exe" Invoke-WebRequest -uri $Source -OutFile $Destination } $webreq = Invoke-WebRequest http://www.symantec.com/security_response/definitions/download/detail.jsp?gid=savce $webreq.Content | Out-File C:\output.txt -Force $txt = (Get-Content -Path C:\output.txt -TotalCount 924)[-1] $src = $txt.Substring(59,59) $des = "c:\" + $txt.Substring(96,22) Invoke-WebRequest -uri $src -OutFile $des $webreq = Invoke-WebRequest http://www.symantec.com/security_response/definitions/download/detail.jsp?gid=savce $gc = $webreq.Content $src = [regex]::Matches("$gc",'http://definitions.symantec.com/defs/.{0,20}\.exe') | Foreach-object {$_.value} #正则表达式 $des = "c:\" + $src[0].substring(37,22) Invoke-WebRequest -uri $src[0] -OutFile $des

 

你可能感兴趣的:(ant)