-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
StartAutomating
authored and
StartAutomating
committed
Jul 29, 2023
1 parent
16a085d
commit 5848514
Showing
1 changed file
with
91 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,106 @@ | ||
### | ||
Get-Demo | ||
-------- | ||
|
||
|
||
```PowerShell | ||
function Get-Demo | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Gets Demos | ||
.DESCRIPTION | ||
Gets PowerShell Demos. | ||
Demos located in ShowDemo and all modules that tag ShowDemo will be automatically discovered. | ||
.LINK | ||
Import-Demo | ||
.EXAMPLE | ||
Get-Demo | ||
#> | ||
[CmdletBinding(DefaultParameterSetName='LoadedDemos')] | ||
param( | ||
# The name of the demo | ||
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='LoadedDemos')] | ||
[string] | ||
$DemoName, | ||
``` | ||
|
||
```PowerShell | ||
# The path to the demo file. | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='DemoFile')] | ||
[Alias('FullName', 'DemoFile', 'File', 'Source')] | ||
$DemoPath, | ||
``` | ||
|
||
```PowerShell | ||
# A Demo Script block. | ||
[Parameter(Mandatory,ValueFromPipeline,ParameterSetName='DemoScript')] | ||
[scriptblock] | ||
$DemoScript | ||
) | ||
``` | ||
### Synopsis | ||
Gets Demos | ||
|
||
```PowerShell | ||
begin { | ||
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module | ||
} | ||
``` | ||
|
||
```PowerShell | ||
process { | ||
if ($PSCmdlet.ParameterSetName -in 'DemoFile', 'DemoScript') { | ||
Import-Demo @psboundParameters | ||
return | ||
} | ||
``` | ||
|
||
--- | ||
|
||
|
||
### Description | ||
|
||
Gets PowerShell Demos. | ||
Demos located in ShowDemo and all modules that tag ShowDemo will be automatically discovered. | ||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Related Links | ||
* [Import-Demo](Import-Demo.md) | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Examples | ||
#### EXAMPLE 1 | ||
```PowerShell | ||
$filePaths = | ||
@( | ||
$pwd | ||
if ($myModule) { | ||
$moduleRelationships = [ModuleRelationships()]$myModule | ||
foreach ($relationship in $moduleRelationships) { | ||
$relationship.RelatedModule | Split-Path | ||
} | ||
} else { | ||
$PSScriptRoot | ||
} | ||
) | ||
Get-Demo | ||
``` | ||
|
||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Parameters | ||
#### **DemoName** | ||
|
||
The name of the demo | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput | | ||
|----------|--------|--------|---------------------| | ||
|`[String]`|false |named |true (ByPropertyName)| | ||
|
||
|
||
|
||
#### **DemoPath** | ||
|
||
The path to the demo file. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput |Aliases | | ||
|----------|--------|--------|---------------------|-----------------------------------------| | ||
|`[Object]`|true |named |true (ByPropertyName)|FullName<br/>DemoFile<br/>File<br/>Source| | ||
|
||
|
||
|
||
#### **DemoScript** | ||
|
||
A Demo Script block. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput | | ||
|---------------|--------|--------|--------------| | ||
|`[ScriptBlock]`|true |named |true (ByValue)| | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Syntax | ||
```PowerShell | ||
$allDemoFiles = | ||
all scripts in $filePaths that { | ||
$_.Name -match '^(?>demo|walkthru)\.ps1$' -or | ||
$_.Name -match '\.(?>demo|walkthru)\.ps1$' | ||
} are demofiles | ||
Get-Demo [-DemoName <String>] [<CommonParameters>] | ||
``` | ||
```PowerShell | ||
Get-Demo -DemoPath <Object> [<CommonParameters>] | ||
``` | ||
|
||
```PowerShell | ||
$allDemoFiles | | ||
Where-Object Name -like "*$demoName*" | | ||
Import-Demo | ||
} | ||
} | ||
Get-Demo -DemoScript <ScriptBlock> [<CommonParameters>] | ||
``` |