Skip to content

Commit dd1da82

Browse files
feat: Get-Servers101 ( Fixes #3 )
1 parent 3ba5570 commit dd1da82

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Commands/Get-Servers101.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
function Get-Servers101
2+
{
3+
<#
4+
.SYNOPSIS
5+
Servers101
6+
.DESCRIPTION
7+
Gets the list of example servers included in Servers101.
8+
9+
Each server is a self-contained PowerShell script.
10+
.EXAMPLE
11+
Get-Servers101
12+
.EXAMPLE
13+
Servers101
14+
#>
15+
[Alias('Servers101')]
16+
param(
17+
# The name of the server. If no name is provided, all servers will be returned.
18+
[SupportsWildcards()]
19+
[string]
20+
$Name
21+
)
22+
23+
begin {
24+
$myModuleRoot = $PSScriptRoot | Split-Path
25+
Update-TypeData -TypeName Servers101 -DefaultDisplayPropertySet Name,
26+
Synopsis, Description -Force
27+
}
28+
process {
29+
Get-ChildItem -File -Path $myModuleRoot -Recurse |
30+
Where-Object {
31+
$_.Name -match 'server?[^\.]{0,}\.ps1$' -and
32+
$_.Name -notmatch '-Server' -and (
33+
(-not $Name) -or ($_.Name -like $name)
34+
)
35+
} |
36+
ForEach-Object {
37+
$file = $_
38+
$help = Get-Help -Name $file.FullName -ErrorAction Ignore
39+
$file.pstypenames.clear()
40+
$file.pstypenames.insert(0,'Servers101')
41+
$file |
42+
Add-Member NoteProperty Synopsis $help.Synopsis -Force -PassThru |
43+
Add-Member NoteProperty Description (
44+
$help.Description.text -join [Environment]::NewLine
45+
) -Force -PassThru
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)