Skip to content

Commit 8ca1677

Browse files
fix merge conflict
2 parents 7abbe9b + c33fcda commit 8ca1677

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/community_snippets.md

+36
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _To contribute, check out our [guide here](#contributing)._
1717
| Table of Contents |
1818
|:------------------|
1919
| [AssertMock](#assert_mock): _Creates assert mock Pester test_ |
20+
| [AWSRegionDynamicParameter](#awsregiondynamicparameter): _Creates a dynamic parameter of current AWS regions by @jbruett_ |
2021
| [CalculatedProperty](#calculatedproperty): _Create a calculated property for use in a select-object call by @corbob_ |
2122
| [DataTable](#datatable): _Creates a DataTable_ |
2223
| [DateTimeWriteVerbose](#datetimewriteverbose): _Write-Verbose with the time and date pre-pended to your message by @ThmsRynr_ |
@@ -51,6 +52,39 @@ Creates Assert Mock for Pester Tests y @SQLDBAWithABeard
5152
}
5253
```
5354

55+
### AWSRegionDynamicParameter
56+
57+
Creates a dynamic parameter of the current AWS regions. Includes parameter validation.
58+
59+
#### Snippet
60+
61+
```json
62+
"AWSRegionDynamicParam": {
63+
"prefix": "aws_region",
64+
"body": [
65+
"DynamicParam {",
66+
"\t$ParamDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary",
67+
"\t$CR_ParamName = 'Region'",
68+
"\t$CR_AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]",
69+
"\t$CR_Attribute = New-Object System.Management.Automation.ParameterAttribute",
70+
"\t$CR_Attribute.HelpMessage = 'List all the regions to be included in the document'",
71+
"\t$CR_Attribute.Mandatory = $true",
72+
"\t$CR_Attribute.ValueFromPipelineByPropertyName = $true",
73+
"\t$CR_AttributeCollection.add($CR_Attribute)",
74+
"\t$CR_intRegions = Get-AWSRegion -IncludeChina | Select-Object -ExpandProperty Region",
75+
"\t$CR_intRegions += Get-AWSRegion -IncludeGovCloud | Select-Object -ExpandProperty Region",
76+
"\t$CR_intRegions = $CR_intRegions | Select-Object -Unique",
77+
"\t$CR_ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($CR_intRegions)",
78+
"\t$CR_AttributeCollection.add($CR_ValidateSetAttribute)",
79+
"\t$CR_Param = New-Object System.Management.Automation.RuntimeDefinedParameter($CR_ParamName, [String[]],$CR_AttributeCollection)",
80+
"\t$ParamDictionary.Add($CR_ParamName, $CR_Param)",
81+
"\treturn $paramDictionary",
82+
"\t}"
83+
],
84+
"description": "A dynamic parameter that builds a list of AWS regions"
85+
}
86+
```
87+
5488
### CalculatedProperty
5589

5690
Create calculated property for use in Select Statements
@@ -122,6 +156,8 @@ Quickly add a `Write-Verbose` with the current date and time inserted before the
122156

123157
Quickly add a fully defined error record and throw. by @omniomi
124158

159+
#### Snippet
160+
125161
```json
126162
"Throw Terminating Error": {
127163
"prefix": "error-terminating",

0 commit comments

Comments
 (0)