PoshCode Archive  Check-in [2c33de7db8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:2c33de7db8c131d8addf304acc36ad444d59198680053d6c5485212ed96e8fd6
User & Date: Wojciech Sciesin 2018-06-10 14:14:59
Context
2018-06-10
14:15
This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script). check-in: ae7c9f604e user: Wojciech Sciesin tags: trunk
14:14
This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script). check-in: 2c33de7db8 user: Wojciech Sciesin tags: trunk
14:14
This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script). check-in: 92165f146a user: Joel Bennett tags: trunk
Changes

Changes to Start-Demo.ps1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# encoding: ascii
# api: powershell
# title: Start-Demo
# description: This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script).
# version: 3.4.0
# type: script
# author: Joel Bennett
# license: CC0
# function: Read-Char
# x-poshcode-id: 6397
# x-derived-from-id: 6398
# x-archived: 2017-01-08T12:30:20
# x-published: 2017-06-18T18:37:00
#
#
## Start-Demo.ps1
##################################################################################################
## This is an overhaul of Jeffrey Snover's original Start-Demo script by Joel "Jaykul" Bennett
##
## I've switched it to using ReadKey instead of ReadLine (you don't have to hit Enter each time)
## As a result, I've changed the names and keys for a lot of the operations, so that they make 
## sense with only a single letter to tell them apart (sorry if you had them memorized).
##
## I've also been adding features as I come across needs for them, and you'll contribute your 
## improvements back to the PowerShell Script repository as well.
##################################################################################################
## Revision History (version 3.4)

## 3.4   Fixed:    FullAuto mode corrected
##       Fixed:    Small corrections of code based on PSScriptAnalyzer 1.6.0 sugestions
##       Added:    Console window title will be set back after a demo end
##       Added:    Own custom prompt can be used under demo
##       Added:    SkipAddTheEndLine switch to don't display 'The end' line
##       Added:    SkipAddDemoTime switch to don't display start/end demo and demo duration in 
##                 a PowerShell console window
##       Added:    backgroundColor parameter added - now PowerShell console don't need to be black 
................................................................................
# More about constructing prompts here: https://technet.microsoft.com/en-us/library/hh847739.aspx
Function prompt { "[PS] >" }

Clear-Host

$_lines = Get-Content $file

If (-not $SkipAddSummary.IsPresent) {
    # Append an extra (do nothing) line on the end so we can still go back after the last line.
    $_lines += "Write-Host 'The End'"
}

$_starttime = [DateTime]::now

Write-Host -nonew -back $backgroundColor -fore $promptColor $(" " * $hostWidth)

If (-not $SkipAddDemoTime) {
    Write-Host -nonew -back $backgroundColor -fore $promptColor @"
<Demo Started :: $(split-path $file -leaf)>$(' ' * ($hostWidth - (18 + $(split-path $file -leaf).Length)))
"@
}
Write-Host -nonew -back $backgroundColor -fore $promptColor "Press"
Write-Host -nonew -back $backgroundColor -fore Red " ? "
Write-Host -nonew -back $backgroundColor -fore $promptColor "for help.$(' ' * ($hostWidth - 17))"
................................................................................
        default {
            Write-Host -Fore Green "`nKey not recognized.  Press ? for help, or ENTER to execute the command."
            $_i-- # back a line, we're gonna step forward when we loop
        }
    }
}
$dur = [DateTime]::Now - $_StartTime
If (-not $SkipAddDemoTime) {
    Write-Host -Fore $promptColor $(
        "<Demo Complete -- $(if ($dur.Hours -gt 0) { '{0}h ' })$(if ($dur.Minutes -gt 0) { '{1}m ' }){2}s>" -f
        $dur.Hours, $dur.Minutes, $dur.Seconds, [DateTime]::Now.ToLongTimeString())
    Write-Host -Fore $promptColor $([DateTime]::now)
}
Write-Host
#Restore oryginal PowerShell host title
$RawUI.WindowTitle = $hostTitle
#Restore oryginal PowerShell prompt
If ($UseMyPropmt.IsPresent) {
    Invoke-Expression -Command "Function Prompt { $OryginalPrompt }" -ErrorAction SilentlyContinue
}




|

|


|
|
|
|













|
>
|







 







|








|







 







|












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# encoding: ascii
# api: powershell
# title: Start-Demo
# description: This is an overhaul of Jeffrey Snover’s original Start-Demo script … I’ve switched it to use ReadKey, which saves you some typing and makes the whole thing seem more natural when you’re demoing, (at least to me). I’ve also added a bunch of command-line options and a couple of features in the process (see the Revision History in the script).
# version: 3.4.1
# type: script
# author: Wojciech Sciesin
# license: CC0
# function: Read-Char
# x-poshcode-id: 6398
# x-derived-from-id: 6399
# x-archived: 2017-01-08T16:43:29
# x-published: 2017-06-18T19:15:00
#
#
## Start-Demo.ps1
##################################################################################################
## This is an overhaul of Jeffrey Snover's original Start-Demo script by Joel "Jaykul" Bennett
##
## I've switched it to using ReadKey instead of ReadLine (you don't have to hit Enter each time)
## As a result, I've changed the names and keys for a lot of the operations, so that they make 
## sense with only a single letter to tell them apart (sorry if you had them memorized).
##
## I've also been adding features as I come across needs for them, and you'll contribute your 
## improvements back to the PowerShell Script repository as well.
##################################################################################################
## Revision History (version 3.4.1)
## 3.4.1 Fixed:    Switches SkipAddTheEndLine and SkipAddDemoTime corrected
## 3.4.0 Fixed:    FullAuto mode corrected
##       Fixed:    Small corrections of code based on PSScriptAnalyzer 1.6.0 sugestions
##       Added:    Console window title will be set back after a demo end
##       Added:    Own custom prompt can be used under demo
##       Added:    SkipAddTheEndLine switch to don't display 'The end' line
##       Added:    SkipAddDemoTime switch to don't display start/end demo and demo duration in 
##                 a PowerShell console window
##       Added:    backgroundColor parameter added - now PowerShell console don't need to be black 
................................................................................
# More about constructing prompts here: https://technet.microsoft.com/en-us/library/hh847739.aspx
Function prompt { "[PS] >" }

Clear-Host

$_lines = Get-Content $file

If (-not $SkipAddTheEndLine.IsPresent) {
    # Append an extra (do nothing) line on the end so we can still go back after the last line.
    $_lines += "Write-Host 'The End'"
}

$_starttime = [DateTime]::now

Write-Host -nonew -back $backgroundColor -fore $promptColor $(" " * $hostWidth)

If (-not $SkipAddDemoTime.IsPresent) {
    Write-Host -nonew -back $backgroundColor -fore $promptColor @"
<Demo Started :: $(split-path $file -leaf)>$(' ' * ($hostWidth - (18 + $(split-path $file -leaf).Length)))
"@
}
Write-Host -nonew -back $backgroundColor -fore $promptColor "Press"
Write-Host -nonew -back $backgroundColor -fore Red " ? "
Write-Host -nonew -back $backgroundColor -fore $promptColor "for help.$(' ' * ($hostWidth - 17))"
................................................................................
        default {
            Write-Host -Fore Green "`nKey not recognized.  Press ? for help, or ENTER to execute the command."
            $_i-- # back a line, we're gonna step forward when we loop
        }
    }
}
$dur = [DateTime]::Now - $_StartTime
If (-not $SkipAddDemoTime.IsPresent) {
    Write-Host -Fore $promptColor $(
        "<Demo Complete -- $(if ($dur.Hours -gt 0) { '{0}h ' })$(if ($dur.Minutes -gt 0) { '{1}m ' }){2}s>" -f
        $dur.Hours, $dur.Minutes, $dur.Seconds, [DateTime]::Now.ToLongTimeString())
    Write-Host -Fore $promptColor $([DateTime]::now)
}
Write-Host
#Restore oryginal PowerShell host title
$RawUI.WindowTitle = $hostTitle
#Restore oryginal PowerShell prompt
If ($UseMyPropmt.IsPresent) {
    Invoke-Expression -Command "Function Prompt { $OryginalPrompt }" -ErrorAction SilentlyContinue
}