3. @Fearless_Shultz #brightonSEO
What I’m Going to Talk About
Today
A Brief Introduction to
what PowerShell is, it's
components and
interface
Some Examples of Using
PowerShell to Automate
SEO Tasks
Extending PowerShell Beyond
It’s Native Capabilities
12. @Fearless_Shultz #brightonSEO
Fear either that scripting is too hard for you to learn and you
won’t be able to do it or that you might break something
*Spoiler – It’s not and You Will. Everyone does
22. @Fearless_Shultz #brightonSEO
Actually, PowerShell is a task-based command-line shell and scripting
language built on .NET which helps system administrators and power-
users rapidly automate tasks that manage operating systems and
processes
But that doesn’t sound as cool…
29. @Fearless_Shultz #brightonSEO
Command Line
A cmdlet (pronounced "command-let") is a lightweight Windows PowerShell script that performs a
single function.
Invoke-WebRequest Import / Export CSVInvokeRestMethod
33. @Fearless_Shultz #brightonSEO
The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web
page or web service. It parses the response and returns collections of
links, images, and other significant HTML elements.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-6
41. @Fearless_Shultz #brightonSEO
innerHTML href
Free SEO Tools https://moz.com/tools
https://moz.com/learn/seo
https://moz.com/training
https://moz.com/beginners-guide-to-seo
SEO Learning Center https://moz.com/learn
Free SEO Tools https://moz.com/free-seo-tools
What is SEO? https://moz.com/learn/seo/what-is-seo
On-Site SEO /learn/seo/on-site
Local SEO /learn/seo/local
Mobile SEO /learn/seo/mobile
International SEO /learn/seo/international
Beginner's Guide to SEO /beginners-guide-to-seo
53. @Fearless_Shultz #brightonSEO
The Invoke-WebRestMethod cmdlet sends HTTP and HTTPS requests to a
web page or web service. It parses the response and returns collections
of links, images, and other significant HTML elements.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6
66. @Fearless_Shultz #brightonSEO
# run the screaming frog crawl
cd "C:Program Files (x86)Screaming Frog SEO Spider"
$env:Path = $env:Path + ";C:Program Files (x86)Screaming Frog SEO Spider"
$startingURL = "https://mikeosolinski.co.uk"
ScreamingFrogSEOSpiderCli.exe
--crawl $startingURL
--headless
--save-crawl
--output-folder “C:scriptssf"
--export-tabs "Internal:HTML,Response Codes:Client Error (4xx)"
https://www.screamingfrog.co.uk/seo-spider/user-guide/general/#commandlineoptions
67. @Fearless_Shultz #brightonSEO
#create an excel document to contain the data
$xl = New-Object -ComObject Excel.Application
$xl.Visible = $true
#add a workbook to the excel object
$workbook1 = $xl.WorkBooks.Add()
#add the sheet to contain long page titles
$lngPageTitles = $workbook1.Worksheets.Item(1)
$lngPageTitles.Name = 'Long Page Titles'
#create the column headers for long page titles
$lngPageTitles.Cells.Item(1,1) = 'Address'
$lngPageTitles.Cells.Item(1,2) = 'Status'
$lngPageTitles.Cells.Item(1,3) = 'Title Length'
68. @Fearless_Shultz #brightonSEO
#import the title length data from the screaming frog crawl
$titledata = Import-Csv -Path ‘C:scriptssfinternal_html.csv'|
select Address, Status,'Title 1 Length'|
where Status -eq 'OK'|
where 'Title 1 Length' -gt 55
#iterate through the records and add data to the sheet
$i = 2
foreach($record in $titledata)
{
$titledata.Address
$titledata.'Title 1 Length'
$lngPageTitles.cells.item($i,1) = $record.Address
$lngPageTitles.cells.item($i,2) = $record.Status
$lngPageTitles.cells.item($i,3) = $record.'Title 1 Length'
$i++
}
71. @Fearless_Shultz #brightonSEO
# CHANGE THE URL BELOW TO THE ONE THAT YOU WANT TO TEST
$urltotest = 'https://mikeosolinski.co.uk'
#update the path to save files to from C:SiteSpeedDataTOOL-OUTPUT to whatever you want. avoid spaces in
path/filenames
#any questions on how to run this ping me on twitter at https://twitter.com/Fearless_Shultz
https://github.com/mikeosolinski/powershell/blob/master/site-speed-data
85. @Fearless_Shultz #brightonSEO
https://github.com/mikeosolinski/powershell/ My Github profile which contains commented versions of all of the scripts mentioned
https://docs.microsoft.com/en-us/skypeforbusiness/set-up-your-computer-for-
windows-powershell/download-and-install-windows-powershell-5-1 The download page to install PowerShell
https://www.powershellgallery.com/ PowerShelll Cmdlet Gallery
https://www.adamtheautomator.com/invoke-webrequest-powershell/ Guide to Invoke-WebRequest
https://www.gngrninja.com/script-ninja/2016/7/8/powershell-getting-started-
utilizing-the-web Another guide to invoke WebRequest
https://stackoverflow.com/questions/11885246/how-do-i-loop-through-a-line-
from-a-csv-file-in-powershell Loops in PowerShell
https://www.youtube.com/watch?v=PXBMdIkH24I Associative Arrays in PowerShell
https://vwiki.co.uk/MySQL_and_PowerShell Accessing MySQL With PowerShell
https://mcpmag.com/articles/2018/08/08/replace-text-with-powershell.aspx Finding and Replacing Text
https://techblog.dorogin.com/generate-word-documents-with-powershell-
cda654b9cb0e Generating Word Documents with PowerShell
https://www.powershellbros.com/powershell-tip-of-the-week-create-invoke-
webrequest-from-chrome/ PowerShell and Google Chrome
https://docs.google.com/spreadsheets/d/1psz6SvRqv7fjIFIiAySPNshObMINjjFeCvGqTjluGLs/edit?usp=sharing