In the previous tip we pointed you to a great compilation of PowerShell cheat sheets. Let’s now check out how easily PowerShell can download these sheets for you:
# enable SSL download $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols # download page $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 | # turn URLs into directly downloadable absolute URLs ForEach-Object { $_.href = 'https://github.com/PrateekKumarSingh/CheatSheets/raw/master/Powershell/' + $_.title $_ } # create folder on your desktop $Path = "$home\Desktop\CheatSheets" $exists = Test-Path -Path $Path if (!$exists) { $null = New-Item -Path $path -ItemType Directory } # download cheat sheets $links | ForEach-Object { $docPath = Join-Path -Path $Path -ChildPath $_.Title Start-BitsTransfer -Source $_.href -Destination $docPath -Description $_.title # alternate way of downloading # Invoke-WebRequest -UseBasicParsing -Uri $_.href -OutFile $docPath } # open folder explorer $Path
When you run this script, PowerShell downloads all cheat sheets and places them into a new folder called “CheatSheets” on your desktop. Happy reading!
psconf.eu – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit www.psconf.eu There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at www.psconf.eu, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!