33function Get-PlasterTemplate {
44 [CmdletBinding ()]
55 param (
6- [Parameter (Position = 0 ,
7- ParameterSetName = " Path" ,
8- HelpMessage = " Specifies a path to a folder containing a Plaster template or multiple template folders. Can also be a path to plasterManifest.xml." )]
6+ [Parameter (Position = 0 ,
7+ ParameterSetName = " Path" ,
8+ HelpMessage = " Specifies a path to a folder containing a Plaster template or multiple template folders. Can also be a path to plasterManifest.xml." )]
99 [ValidateNotNullOrEmpty ()]
1010 [string ]
1111 $Path ,
1212
13- [Parameter (Position = 1 ,
14- ParameterSetName = " Path" ,
15- HelpMessage = " Will return templates that match the name." )]
16- [Parameter (Position = 1 ,
17- ParameterSetName = " IncludedTemplates" ,
18- HelpMessage = " Will return templates that match the name." )]
13+ [Parameter (Position = 1 ,
14+ ParameterSetName = " Path" ,
15+ HelpMessage = " Will return templates that match the name." )]
16+ [Parameter (Position = 1 ,
17+ ParameterSetName = " IncludedTemplates" ,
18+ HelpMessage = " Will return templates that match the name." )]
1919 [ValidateNotNullOrEmpty ()]
2020 [string ]
2121 $Name = " *" ,
2222
23- [Parameter (ParameterSetName = " Path" ,
24- HelpMessage = " Will return templates that match the tag." )]
25- [Parameter (ParameterSetName = " IncludedTemplates" ,
26- HelpMessage = " Will return templates that match the tag." )]
23+ [Parameter (ParameterSetName = " Path" ,
24+ HelpMessage = " Will return templates that match the tag." )]
25+ [Parameter (ParameterSetName = " IncludedTemplates" ,
26+ HelpMessage = " Will return templates that match the tag." )]
2727 [ValidateNotNullOrEmpty ()]
2828 [string ]
2929 $Tag = " *" ,
3030
31- [Parameter (ParameterSetName = " Path" ,
32- HelpMessage = " Indicates that this cmdlet gets the items in the specified locations and in all child items of the locations." )]
31+ [Parameter (ParameterSetName = " Path" ,
32+ HelpMessage = " Indicates that this cmdlet gets the items in the specified locations and in all child items of the locations." )]
3333 [switch ]
3434 $Recurse ,
3535
36- [Parameter (Position = 0 ,
37- Mandatory = $true ,
38- ParameterSetName = " IncludedTemplates" ,
39- HelpMessage = " Initiates a search for latest version Plaster templates inside of installed modules." )]
36+ [Parameter (Position = 0 ,
37+ Mandatory = $true ,
38+ ParameterSetName = " IncludedTemplates" ,
39+ HelpMessage = " Initiates a search for latest version Plaster templates inside of installed modules." )]
4040 [switch ]
4141 [Alias (" IncludeModules" )]
4242 $IncludeInstalledModules ,
43-
44- [Parameter (ParameterSetName = " IncludedTemplates" ,
45- HelpMessage = " If specified, searches for Plaster templates inside of all installed module versions." )]
43+
44+ [Parameter (ParameterSetName = " IncludedTemplates" ,
45+ HelpMessage = " If specified, searches for Plaster templates inside of all installed module versions." )]
4646 [switch ]
4747 $ListAvailable
4848 )
@@ -54,17 +54,17 @@ function Get-PlasterTemplate {
5454 $metadata = $manifestXml [" plasterManifest" ][" metadata" ]
5555
5656 $manifestObj = [PSCustomObject ]@ {
57- Name = $metadata [" name" ].InnerText
58- Title = $metadata [" title" ].InnerText
59- Author = $metadata [" author" ].InnerText
60- Version = New-Object - TypeName " System.Version" - ArgumentList $metadata [" version" ].InnerText
61- Description = $metadata [" description" ].InnerText
62- Tags = $metadata [" tags" ].InnerText.split(" ," ) | % { $_.Trim () }
57+ Name = $metadata [" name" ].InnerText
58+ Title = $metadata [" title" ].InnerText
59+ Author = $metadata [" author" ].InnerText
60+ Version = New-Object - TypeName " System.Version" - ArgumentList $metadata [" version" ].InnerText
61+ Description = $metadata [" description" ].InnerText
62+ Tags = $metadata [" tags" ].InnerText.split(" ," ) | ForEach-Object { $_.Trim () }
6363 TemplatePath = $manifestPath.Directory.FullName
6464 }
6565
6666 $manifestObj.PSTypeNames.Insert (0 , " Microsoft.PowerShell.Plaster.PlasterTemplate" )
67- Add-Member - MemberType ScriptMethod - InputObject $manifestObj - Name " InvokePlaster" - Value {Invoke-Plaster - TemplatePath $this.TemplatePath }
67+ Add-Member - MemberType ScriptMethod - InputObject $manifestObj - Name " InvokePlaster" - Value { Invoke-Plaster - TemplatePath $this.TemplatePath }
6868 return $manifestObj | Where-Object Name -like $name | Where-Object Tags -like $tag
6969 }
7070
@@ -85,34 +85,32 @@ function Get-PlasterTemplate {
8585 # Use Test-PlasterManifest to load the manifest file
8686 Write-Verbose " Attempting to get Plaster template at path: $Path "
8787 CreateTemplateObjectFromManifest $Path $Name $Tag
88- }
89- else {
88+ } else {
9089 Write-Verbose " Attempting to get Plaster templates recursively under path: $Path "
9190 GetManifestsUnderPath $Path $Recurse.IsPresent $Name $Tag
9291 }
93- }
94- else {
92+ } else {
9593 # Return all templates included with Plaster
9694 GetManifestsUnderPath " $PSScriptRoot \Templates" $true $Name $Tag
9795
9896 if ($IncludeInstalledModules.IsPresent ) {
9997 # Search for templates in module path
10098 $GetModuleExtensionParams = @ {
101- ModuleName = " Plaster"
99+ ModuleName = " Plaster"
102100 ModuleVersion = $PlasterVersion
103101 ListAvailable = $ListAvailable
104102 }
105-
103+
106104 $extensions = Get-ModuleExtension @GetModuleExtensionParams
107105
108106 foreach ($extension in $extensions ) {
109107 # Scan all module paths registered in the module
110108 foreach ($templatePath in $extension.Details.TemplatePaths ) {
111109 $expandedTemplatePath =
112- [System.IO.Path ]::Combine(
113- $extension.Module.ModuleBase ,
114- $templatePath ,
115- " plasterManifest.xml" )
110+ [System.IO.Path ]::Combine(
111+ $extension.Module.ModuleBase ,
112+ $templatePath ,
113+ " plasterManifest.xml" )
116114
117115 CreateTemplateObjectFromManifest $expandedTemplatePath $Name $Tag - ErrorAction SilentlyContinue
118116 }
0 commit comments