-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGet-PowerShellGuide.ps.ps1
More file actions
42 lines (36 loc) · 1.41 KB
/
Copy pathGet-PowerShellGuide.ps.ps1
File metadata and controls
42 lines (36 loc) · 1.41 KB
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
function Get-PowerShellGuide
{
[CmdletBinding(DefaultParameterSetName='NoTopic')]
[Alias('Get-PSGuide')]
param(
[Parameter(Mandatory,ParameterSetName='Topic',ValueFromPipelineByPropertyName)]
[Alias('TopicName')]
[string]
$Topic
)
process {
if ($PSCmdlet.ParameterSetName -eq 'NoTopic') {
if (-not $script:CachedPowerShellGuide) {
$guideTopics =
Get-ChildItem -Path $PSScriptRoot -Filter Guide |
Get-ChildItem -Recurse |
Where-Object Extension -in '.md' |
Where-Object FullName -notlike '*_site*'
$guideTopics = @(all in $guideTopics are 'PowerShell Guide Topic File')
$myModuleVersion = $MyInvocation.MyCommand.ScriptBlock.Module.Version
$script:CachedPowerShellGuide = [PSCustomObject]@{
PSTypeName = 'PowerShell.Guide'
Version = $myModuleVersion
AllTopics = $guideTopics
AllDemos = $guideDemos
}
}
$script:CachedPowerShellGuide
}
if ($PSCmdlet.ParameterSetName -eq 'Topic') {
$psGuide = Get-PowerShellGuide
$psGuide.AllTopics |
Where-Object Aliases -like $Topic
}
}
}