@@ -39,18 +39,18 @@ Creates Assert Mock for Pester Tests y @SQLDBAWithABeard
3939#### Snippet
4040
4141``` json
42- "AssertMock" : {
43- "prefix" : " AssertMock" ,
44- "body" : [
45- " $$assertMockParams = @{" ,
46- " 'CommandName' = '${1:Command}'" ,
47- " 'Times' = ${2:1}" ,
48- " 'Exactly' = $$true" ,
49- " }" ,
50- " Assert-MockCalled @assertMockParams"
51- ],
52- "description" : " AssertMock snippet for Pestering"
53- }
42+ "AssertMock" : {
43+ "prefix" : " AssertMock" ,
44+ "body" : [
45+ " $$assertMockParams = @{" ,
46+ " \t 'CommandName' = '${1:Command}'" ,
47+ " \t 'Times' = ${2:1}" ,
48+ " \t 'Exactly' = $$true" ,
49+ " }" ,
50+ " Assert-MockCalled @assertMockParams"
51+ ],
52+ "description" : " AssertMock snippet for Pestering"
53+ }
5454```
5555
5656### AWSRegionDynamicParameter
@@ -61,28 +61,28 @@ Creates a dynamic parameter of the current AWS regions. Includes parameter vali
6161
6262``` json
6363"AWSRegionDynamicParam" : {
64- "prefix" : " aws_region" ,
65- "body" : [
66- " DynamicParam {" ,
67- " \t $ParamDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary" ,
68- " \t $CR_ParamName = 'Region'" ,
69- " \t $CR_AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]" ,
70- " \t $CR_Attribute = New-Object System.Management.Automation.ParameterAttribute" ,
71- " \t $CR_Attribute.HelpMessage = 'List all the regions to be included in the document'" ,
72- " \t $CR_Attribute.Mandatory = $true" ,
73- " \t $CR_Attribute.ValueFromPipelineByPropertyName = $true" ,
74- " \t $CR_AttributeCollection.add($CR_Attribute)" ,
75- " \t $CR_intRegions = Get-AWSRegion -IncludeChina | Select-Object -ExpandProperty Region" ,
76- " \t $CR_intRegions += Get-AWSRegion -IncludeGovCloud | Select-Object -ExpandProperty Region" ,
77- " \t $CR_intRegions = $CR_intRegions | Select-Object -Unique" ,
78- " \t $CR_ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($CR_intRegions)" ,
79- " \t $CR_AttributeCollection.add($CR_ValidateSetAttribute)" ,
80- " \t $CR_Param = New-Object System.Management.Automation.RuntimeDefinedParameter($CR_ParamName, [String[]],$CR_AttributeCollection)" ,
81- " \t $ParamDictionary.Add($CR_ParamName, $CR_Param)" ,
82- " \t return $paramDictionary" ,
83- " \t }"
84- ],
85- "description" : " A dynamic parameter that builds a list of AWS regions"
64+ "prefix" : " aws_region" ,
65+ "body" : [
66+ " DynamicParam {" ,
67+ " \t $ParamDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary" ,
68+ " \t $CR_ParamName = 'Region'" ,
69+ " \t $CR_AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]" ,
70+ " \t $CR_Attribute = New-Object System.Management.Automation.ParameterAttribute" ,
71+ " \t $CR_Attribute.HelpMessage = 'List all the regions to be included in the document'" ,
72+ " \t $CR_Attribute.Mandatory = $true" ,
73+ " \t $CR_Attribute.ValueFromPipelineByPropertyName = $true" ,
74+ " \t $CR_AttributeCollection.add($CR_Attribute)" ,
75+ " \t $CR_intRegions = Get-AWSRegion -IncludeChina | Select-Object -ExpandProperty Region" ,
76+ " \t $CR_intRegions += Get-AWSRegion -IncludeGovCloud | Select-Object -ExpandProperty Region" ,
77+ " \t $CR_intRegions = $CR_intRegions | Select-Object -Unique" ,
78+ " \t $CR_ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($CR_intRegions)" ,
79+ " \t $CR_AttributeCollection.add($CR_ValidateSetAttribute)" ,
80+ " \t $CR_Param = New-Object System.Management.Automation.RuntimeDefinedParameter($CR_ParamName, [String[]],$CR_AttributeCollection)" ,
81+ " \t $ParamDictionary.Add($CR_ParamName, $CR_Param)" ,
82+ " \t return $paramDictionary" ,
83+ " \t }"
84+ ],
85+ "description" : " A dynamic parameter that builds a list of AWS regions"
8686}
8787```
8888
@@ -94,11 +94,11 @@ Create calculated property for use in Select Statements
9494
9595``` json
9696"Add Calculated Property" : {
97- "prefix" : " cf" ,
98- "body" : [
99- " @{'Name' = '$1' ; 'Expression' = {$2}}" ,
100- ],
101- "description" : " Create calculated property for use in Select Statements"
97+ "prefix" : " cf" ,
98+ "body" : [
99+ " @{'Name' = '$1' ; 'Expression' = {$2}}" ,
100+ ],
101+ "description" : " Create calculated property for use in Select Statements"
102102}
103103```
104104
@@ -110,31 +110,31 @@ Quickly create a Data Table object by @SQLDBAWithABeard.
110110
111111``` json
112112"DataTable" : {
113- "prefix" : " DataTable" ,
114- "body" : [
115- " # Create DataTable Object" ,
116- " $$table = New-Object system.Data.DataTable $$TableName" ,
113+ "prefix" : " DataTable" ,
114+ "body" : [
115+ " # Create DataTable Object" ,
116+ " $$table = New-Object system.Data.DataTable $$TableName" ,
117117
118- " \r # Create Columns" ,
119- " $$col1 = New-Object system.Data.DataColumn NAME1,([string])" ,
120- " $$col2 = New-Object system.Data.DataColumn NAME2,([decimal])" ,
118+ " \r # Create Columns" ,
119+ " $$col1 = New-Object system.Data.DataColumn NAME1,([string])" ,
120+ " $$col2 = New-Object system.Data.DataColumn NAME2,([decimal])" ,
121121
122- " \r #Add the Columns to the table" ,
123- " $$table.columns.add($$col1)" ,
124- " $$table.columns.add($$col2)" ,
122+ " \r #Add the Columns to the table" ,
123+ " $$table.columns.add($$col1)" ,
124+ " $$table.columns.add($$col2)" ,
125125
126- " \r # Create a new Row" ,
127- " $$row = $$table.NewRow() " ,
126+ " \r # Create a new Row" ,
127+ " $$row = $$table.NewRow() " ,
128128
129- " \r # Add values to new row" ,
130- " $$row.Name1 = 'VALUE'" ,
131- " $$row.NAME2 = 'VALUE'" ,
129+ " \r # Add values to new row" ,
130+ " $$row.Name1 = 'VALUE'" ,
131+ " $$row.NAME2 = 'VALUE'" ,
132132
133- " \r #Add new row to table" ,
134- " $$table.Rows.Add($$row)"
135- ],
136- "description" : " Creates a Data Table Object"
137- }
133+ " \r #Add new row to table" ,
134+ " $$table.Rows.Add($$row)"
135+ ],
136+ "description" : " Creates a Data Table Object"
137+ }
138138```
139139
140140### DateTimeWriteVerbose
@@ -181,14 +181,14 @@ Add If Should Process with easy tab inputs
181181
182182``` json
183183"IfShouldProcess" : {
184- "prefix" : " IfShouldProcess" ,
185- "body" : [
186- " if ($$PSCmdlet.ShouldProcess(\" ${1:The Item}\" , \" ${2:The Change}\" )) {" ,
187- " # Place Code here" ,
188- " }"
189- ],
190- "description" : " Creates an if should process"
191- }
184+ "prefix" : " IfShouldProcess" ,
185+ "body" : [
186+ " if ($$PSCmdlet.ShouldProcess(\" ${1:The Item}\" , \" ${2:The Change}\" )) {" ,
187+ " \t # Place Code here" ,
188+ " }"
189+ ],
190+ "description" : " Creates an if should process"
191+ }
192192```
193193
194194### MaxColumnLengthinDataTable
@@ -198,22 +198,22 @@ Takes a datatable object and iterates through it to get the max length of the st
198198#### Snippet
199199
200200``` json
201- "Max Length of Datatable" : {
202- "prefix" : " Max Length of Datatable" ,
203- "body" : [
204- " $$columns = ($$datatable | Get-Member -MemberType Property).Name" ,
205- " foreach($$column in $$Columns) {" ,
206- " $$max = 0" ,
207- " foreach ($$a in $$datatable){" ,
208- " if ($$max -lt $$a.$$column.length){" ,
209- " $$max = $$a.$$column.length" ,
210- " }" ,
211- " }" ,
212- " Write -Output \" $$column max length is $$max\" " ,
213- " }"
214- ],
215- "description" : " Takes a datatable object and iterates through it to get the max length of the string columns - useful for data loads"
216- }
201+ "Max Length of Datatable" : {
202+ "prefix" : " Max Length of Datatable" ,
203+ "body" : [
204+ " $$columns = ($$datatable | Get-Member -MemberType Property).Name" ,
205+ " foreach($$column in $$Columns) {" ,
206+ " \t $$max = 0" ,
207+ " \t foreach ($$a in $$datatable){" ,
208+ " \t\t if ($$max -lt $$a.$$column.length){" ,
209+ " \t\t\t $$max = $$a.$$column.length" ,
210+ " \t\t }" ,
211+ " \t }" ,
212+ " \t Write -Output \" $$column max length is $$max\" " ,
213+ " }"
214+ ],
215+ "description" : " Takes a datatable object and iterates through it to get the max length of the string columns - useful for data loads"
216+ }
217217```
218218
219219### Parameter-Credential
@@ -244,15 +244,15 @@ Quickly create a Pester Test for existence of a mandatory parameter by @SQLDBAWi
244244#### Snippet
245245
246246``` json
247- "Pester for Mandatory Pester " : {
248- "prefix" : " mandatoryParamPester" ,
249- "body" : [
250- " It \" ${1:FunctionName} Should have a mandatory parameter ${2:ParameterName}\" {" ,
251- " (Get-Command ${1:FunctionName}).Parameters['${2:ParameterName}'].Attributes.Mandatory | Should -BeTrue" ,
252- " }"
253- ],
254- "description" : " Pester Test for Parameter"
255- }
247+ "Pester for Mandatory Parameter " : {
248+ "prefix" : " mandatoryParamPester" ,
249+ "body" : [
250+ " It \" ${1:FunctionName} Should have a mandatory parameter ${2:ParameterName}\" {" ,
251+ " \t (Get-Command ${1:FunctionName}).Parameters['${2:ParameterName}'].Attributes.Mandatory | Should -BeTrue" ,
252+ " }"
253+ ],
254+ "description" : " Pester Test for Parameter"
255+ }
256256```
257257
258258### PesterTestForParameter
@@ -262,15 +262,15 @@ Quickly create a Pester Test for existence of a parameter by @SQLDBAWithABeard
262262#### Snippet
263263
264264``` json
265- "Pester for Parameter" : {
266- "prefix" : " Param Pester" ,
267- "body" : [
268- " It \" ${1:FunctionName} Should have a parameter ${2:ParameterName}\" {" ,
269- " (Get-Command ${1:FunctionName}).Parameters['${2:ParameterName}'].Count | Should -Be 1" ,
270- " }"
271- ],
272- "description" : " Pester Test for Parameter"
273- }
265+ "Pester for Parameter" : {
266+ "prefix" : " Param Pester" ,
267+ "body" : [
268+ " It \" ${1:FunctionName} Should have a parameter ${2:ParameterName}\" {" ,
269+ " \t (Get-Command ${1:FunctionName}).Parameters['${2:ParameterName}'].Count | Should -Be 1" ,
270+ " }"
271+ ],
272+ "description" : " Pester Test for Parameter"
273+ }
274274```
275275
276276### PSCustomObject
@@ -305,7 +305,7 @@ Use the `#region` for organizing your code (including good code folding).
305305 "prefix" : " #region" ,
306306 "body" : [
307307 " #region ${1}" ,
308- " ${2} " ,
308+ " $0 " ,
309309 " #endregion"
310310 ],
311311 "description" : " Region Block for organizing and folding of your code"
0 commit comments