-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathGet-Scripts.ps1
41 lines (33 loc) · 1.07 KB
/
Get-Scripts.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
<#
.SYNOPSIS
List all external scripts and their parameter names. These are all of the
scripts implemented in your WindowsPowerShell profile Modules/Scripts folder.
.DESCRIPTION
Any aliases are listed along with each command.
#>
$sysparams = @(
'Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'InformationAction', 'ErrorVariable',
'WarningVariable', 'InformationVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable'
)
$aliases = @{}
Get-Alias | % { if ($aliases[$_.Definition] -eq $null) { $aliases.Add($_.Definition, $_.Name) } }
Get-Command -CommandType ExternalScript | % `
{
$name = [IO.Path]::GetFileNameWithoutExtension($_.Name)
Write-Host "$name " -NoNewline
$parameters = $_.Parameters
if ($parameters -ne $null)
{
$parameters.Keys | ? { $sysparams -notcontains $_ } | % `
{
$p = $parameters[$_]
$c = if ($p.ParameterType -like 'Switch') { 'DarkGray' } else { 'DarkCyan' }
Write-Host "-$_ " -NoNewline -ForegroundColor $c
}
}
$alias = $aliases[$name]
if ($alias) {
Write-Host " ($alias)" -ForegroundColor DarkGreen -NoNewline
}
Write-Host
}