Home > Powershell > Function: Get-Documentation

Function: Get-Documentation

Righto – As mentioned here in Get-Screenshot we can easily capture our working screen. Now more than just the novelty of having a .png file filling up a random folder…. think this concept through to automatically documenting a script / build / app install.

Function Get-Documentation ($cmd,$filename="screenshot",$fold="C:\wiki\Get-Documentation",[switch]$PAUSE,[switch]$CLS,[switch]$DISPLAY)
{
	# note use of script block $cmd =  {gf get-screenshot -de}
	# syntax Get-Documentation -cmd {gf get-screenshot -de} -PAUSE -CLS -DISPLAY

	if ($CLS) {clear}
	"`nRunning command ""$cmd""`n" | Write-Host -ForegroundColor Green
	. $cmd

	sleep 1
	if ($PAUSE) {pause}
	if ($display) {get-screenshot $filename -fold $fold  -DISPLAY} else {get-screenshot $filename -fold $fold}
}

Talking through the various param options:
$cmd………………..is the script block to execute
$filename……………name of the file, with a default of “screenshot”, but will also have datestamp appended
$fold…………………folder, default is “C:\wiki\Documentation”
[switch]$PAUSE……wait for user input before continuing
[switch]$CLS……….clear the powershell window before executing the script block
[switch]$DISPLAY….invoke the screengrab (for review purposes)

sample output from running command:
Get-Documentation {gf get-screenshot -de} SampleScreenShot -PAUSE -CLS -DISPLAY
get-screenshot

tbc.

Advertisements
Categories: Powershell
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: