@@ -39,18 +39,18 @@ Creates Assert Mock for Pester Tests y @SQLDBAWithABeard
39
39
#### Snippet
40
40
41
41
``` 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
+ }
54
54
```
55
55
56
56
### AWSRegionDynamicParameter
@@ -61,28 +61,28 @@ Creates a dynamic parameter of the current AWS regions. Includes parameter vali
61
61
62
62
``` json
63
63
"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"
86
86
}
87
87
```
88
88
@@ -94,11 +94,11 @@ Create calculated property for use in Select Statements
94
94
95
95
``` json
96
96
"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"
102
102
}
103
103
```
104
104
@@ -110,31 +110,31 @@ Quickly create a Data Table object by @SQLDBAWithABeard.
110
110
111
111
``` json
112
112
"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" ,
117
117
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])" ,
121
121
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)" ,
125
125
126
- " \r # Create a new Row" ,
127
- " $$row = $$table.NewRow() " ,
126
+ " \r # Create a new Row" ,
127
+ " $$row = $$table.NewRow() " ,
128
128
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'" ,
132
132
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
+ }
138
138
```
139
139
140
140
### DateTimeWriteVerbose
@@ -181,14 +181,14 @@ Add If Should Process with easy tab inputs
181
181
182
182
``` json
183
183
"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
+ }
192
192
```
193
193
194
194
### MaxColumnLengthinDataTable
@@ -198,22 +198,22 @@ Takes a datatable object and iterates through it to get the max length of the st
198
198
#### Snippet
199
199
200
200
``` 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
+ }
217
217
```
218
218
219
219
### Parameter-Credential
@@ -244,15 +244,15 @@ Quickly create a Pester Test for existence of a mandatory parameter by @SQLDBAWi
244
244
#### Snippet
245
245
246
246
``` 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
+ }
256
256
```
257
257
258
258
### PesterTestForParameter
@@ -262,15 +262,15 @@ Quickly create a Pester Test for existence of a parameter by @SQLDBAWithABeard
262
262
#### Snippet
263
263
264
264
``` 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
+ }
274
274
```
275
275
276
276
### PSCustomObject
@@ -305,7 +305,7 @@ Use the `#region` for organizing your code (including good code folding).
305
305
"prefix" : " #region" ,
306
306
"body" : [
307
307
" #region ${1}" ,
308
- " ${2} " ,
308
+ " $0 " ,
309
309
" #endregion"
310
310
],
311
311
"description" : " Region Block for organizing and folding of your code"
0 commit comments