Witam wszystkich
Chodzi mi o to żeby $Page=1
zmieniał się np. od 1
do 10
w pętli. Teraz wygląda to tak że uruchamiam ten skrypt, jak się skończy to wpisuję ręcznie $Page=2
i znowu puszczam.
Nie znam się na Powershell, szukałem w internecie jakichś pętli ale nie wiem nawet gdzie i jak je wstawić.
Dziękuję z góry za pomoc.
function Download-Wallpaper
{
param
(
[string]
[Parameter(Mandatory)]
$Folder,
[Parameter(ValueFromPipeline)]
[Int]
$Page=1
)
begin
{
$url = "http://wallpaperswide.com/page/$Page"
$targetExists = Test-Path -Path $Folder
if (!$targetExists) { $null = New-Item -Path $Folder -ItemType Directory }
}
process
{
$web = Invoke-WebRequest -Uri $url -UseBasicParsing
$web.Images.src |
ForEach-Object {
$filename = $_.Split('/')[-1].Replace('t1.jpg','wallpaper-3840x2160.jpg')
$source = "http://wallpaperswide.com/download/$filename"
$TargetPath = Join-Path -Path $folder -ChildPath $filename
Invoke-WebRequest -Uri $source -OutFile $TargetPath
}
}
end
{
explorer $Folder
}
}
Download-Wallpaper -Folder d:\temp\wallpaper