HOWTO: Easily add Powershell code to a WordPress Blog Post using Windows Live Writer

Have you ever wanted to publish Powershell code (or other languages) directly to a WordPress blog such that it automatically is syntax colored and line numbered?  Now you can!  Here’s how:

image

  • From Live Writer select Insert from the ribbon and choose

image

  • Copy and paste your powershell code into the window and be sure to select the Code Language as powershell and press OK

image

# This is some sample Powershell
# It doesn't do anything of value

$Result = Get-Service | Where { $_.DisplayName -match "Update" }
$Result = $Result.DisplayName | select -first 1

Write-host "The service $Result is present" -BackgroundColor Yellow
  • Publish your blog post and enjoy the nicely formatted Powershell code

1 comments

  1. It’s remarkable in support of me to have a site, which is beneficial for my knowledge.

    thanks admin

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.