<# .Synopsis Short description .DESCRIPTION Long description .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet #> function Get-Newer { [CmdletBinding()] Param ( # Remote files' URLs [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] $Source, # Local files' paths [Parameter(ValueFromPipelineByPropertyName=$true)] $Destination ) Process{ try { $okay = $false $localfile = $PSItem.Destination | Get-Item -ErrorAction Stop #если ошибка доступа к файлу или его нет [DateTime]$localtime = $localfile.LastWriteTime #возможные исключения в .Net методах Create и GetResponse не обработаны [DateTime]$remotetime = [Net.HttpWebRequest]::Create($PSItem.Source).GetResponse() | Select -ExpandProperty LastModified if ($remotetime -gt $localtime){ $okay = $true } else { Write-Warning ("{0} is not newer, skipping" -f $localfile.FullName) } } catch { # обработано только исключение "нет такого локального файла": ошибка доступа провалится сюда же $okay = $true } if ($okay){ Write-Verbose ("Included: {0}" -f $PSItem.Source) Write-Output $PSItem } } } $root = 'E:\WgetSoft01' function Get-LocalFile { [OutputType([System.IO.FileInfo])] param ( [Parameter(ValueFromPipeline)] [string]$remote ) $local = join-path $root ($remote -split '/')[-1] | get-item return $local } Import-CSV C:\soft.txt | Get-Newer | Start-BitsTransfer |