forked from bcdady/MyScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvoke-SelectedHistory.ps1
65 lines (49 loc) · 1.26 KB
/
Invoke-SelectedHistory.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<#PSScriptInfo
.VERSION 1.0
.GUID 018057d7-7bab-4727-817c-e8c89ea01d53
.AUTHOR Jeffrey Snover
.COMPANYNAME
.COPYRIGHT
.TAGS
.LICENSEURI
.PROJECTURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
.DESCRIPTION
Show the command line history and Invoke the selected items
#>
<#
.Synopsis
Show the command line history and Invoke the selected items
.DESCRIPTION
Essentially this does:
PS> Get-History -count:$count | Out-Gridview -Passthru | Invoke-History
The benefit is that you can do searching and multiple selections.
.EXAMPLE
PS> Invoke-SelectedHistory -Whatif
.EXAMPLE
PS> ISH -count 200 -verbose
.INPUTS
None
.OUTPUTS
Output of the selected command
.COMPONENT
.ROLE
.FUNCTIONALITY
#>
[CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')]
[Alias("ish")]
Param(
# How many things from history should be shown?
[Parameter(Mandatory=0,position=0)][Int]$Count= 100 )
foreach($cmd in Get-History -Count:$count |Select Id,CommandLIne,ExecutionStatus,StartExecutionTIme |Out-GridView -PassThru -Title "Select 1 or more commands to invoke" )
{
if ($pscmdlet.ShouldProcess($cmd.commandline, "Invoke"))
{
Invoke-History -Id $cmd.Id
}
}