在前一个技能中我们提供了一个很棒的 PowerShell 速查表。让我们来看看 PowerShell 能够怎样下载这些速查表:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
$url = "https://github.com/PrateekKumarSingh/CheatSheets/tree/master/Powershell" $page = Invoke-WebRequest -UseBasicParsing -Uri $url $links = $page.Links | Where-Object { $_.href -like '*.pdf' } | Select-Object -Property title, href | ForEach-Object { $_.href = 'https://github.com/PrateekKumarSingh/CheatSheets/raw/master/Powershell/' + $_.title $_ }
$Path = "$home\Desktop\CheatSheets" $exists = Test-Path -Path $Path if (!$exists) { $null = New-Item -Path $path -ItemType Directory }
$links | ForEach-Object { $docPath = Join-Path -Path $Path -ChildPath $_.Title Start-BitsTransfer -Source $_.href -Destination $docPath -Description $_.title }
explorer $Path
|
当您运行这段脚本时,PowerShell 将下载所有的速查表并且将它们存放在桌面上一个名为 “CheatSheets” 的新文件夹中。祝您读得愉快!