Interesting PowerShell snippets
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Get-FileHash.ps1
Get-ForsquareJavaApiInfo.ps1
Get-QRCodeInExplorer.ps1
Get-ReadmeHash.ps1
Microsoft.PowerShell_profile.ps1
README.md
Sign-File.ps1
_vimrc

README.md

powershell-examples

Interesting PowerShell snippets

Internet Explorer interaction

Get-QRCodeInExplorer.ps1

  • integration of PowerShell and Internet Explorer, useful for automating web tests
  • creates instance of Internet Explorer, modify DOM element and dispatch JavaScript event

PowerShell profile

Microsoft.PowerShell_profile.ps1

  • example of PowerShell profile, you can store it to ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  • contains setting $env:PATH variable for Python and Ruby
  • contains setting $env:SVN_EDITOR to vim
  • contains setting $env:NODE_PATH to proper location of NodeJS local data on Windows
  • changing color of command prompt

Signing Scripts

Sign-File.ps1

  • specify path to PowerShell script as parameter
  • the script will append signature to this will
  • you can set up private certificate by calling commands from Visual Studio Command Prompt:
makecert -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine
makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer

SHA1 hash

Get-ReadmeHash.ps1

  • use System.Security.Cryptography.SHA1Managed functions to compute SHA1 of README.md file

Get-FileHash.ps1

  • compute SHA1 of file specified as parameter

Vim configuration for PowerShell

_vimrc

XML parsing

Get-ForsquareJavaApiInfo.ps1

  • download pom.xml from internet, parse xml data and display version and license of Forsquare Java API