Skip to content

Commit c7336de

Browse files
authored
Merge pull request #1 from PowerShell/master
Sync from original.
2 parents 3580fe9 + ab5ee30 commit c7336de

File tree

1 file changed

+55
-16
lines changed

1 file changed

+55
-16
lines changed

docs/community_snippets.md

+55-16
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,27 @@ _To contribute, check out our [guide here](#contributing)._
1515
## Table of contents
1616

1717
| Table of Contents |
18-
|:-----------------:|
19-
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject by @brettmillerb_ |
18+
|:------------------|
19+
| [CalculatedProperty](#calculatedproperty): _Create a calculated property for use in a select-object call by @corbob_ |
2020
| [DateTimeWriteVerbose](#datetimewriteverbose): _Write-Verbose with the time and date pre-pended to your message by @ThmsRynr_ |
21+
| [Parameter-Credential](#parameter-credential): _Add a standard credential parameter to your function by @omniomi_ |
22+
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject by @brettmillerb_ |
2123

2224
## Snippets
2325

24-
### PSCustomObject
26+
### CalculatedProperty
2527

26-
A simple PSCustomObject by @brettmillerb. It has 4 properties that you can tab through to quickly fill in.
28+
Create calculated property for use in Select Statements
2729

2830
#### Snippet
2931

3032
```json
31-
"PSCustomObject": {
32-
"prefix": "PSCustomObject",
33-
"body": [
34-
"[PSCustomObject]@{\r",
35-
"\t${item1} = ${Property1}\r",
36-
"\t${item2} = ${Property2}\r",
37-
"\t${item3} = ${Property3}\r",
38-
"\t${item4} = ${Property4}\r",
39-
"}"
40-
],
41-
"description": "Creates a PSCustomObject"
33+
"Add Calculated Property": {
34+
"prefix": "cf",
35+
"body": [
36+
"@{'Name' = '$1' ; 'Expression' = {$2}}",
37+
],
38+
"description": "Create calculated property for use in Select Statements"
4239
}
4340
```
4441

@@ -58,6 +55,48 @@ Quickly add a `Write-Verbose` with the current date and time inserted before the
5855
}
5956
```
6057

58+
### Parameter-Credential
59+
60+
Add a `-Credential` parameter that supports a PSCredential object in a variable, `-Credential (Get-Credential)`, or `-Credential Username` (will prompt). Includes an empty PSCredential object as the default value but this is the first tabstop so pressing backspace after inserting the snippet removes it. by @omniomi
61+
62+
#### Snippet
63+
64+
```json
65+
"Parameter-Credential": {
66+
"prefix": "parameter-credential",
67+
"body": [
68+
"# Specifies the user account credentials to use when performing this task.\r",
69+
"[Parameter()]\r",
70+
"[ValidateNotNull()]\r",
71+
"[System.Management.Automation.PSCredential]\r",
72+
"[System.Management.Automation.Credential()]\r",
73+
"$$Credential${1: = [System.Management.Automation.PSCredential]::Empty}"
74+
],
75+
"description": "Parameter declaration snippet for a Credential parameter."
76+
}
77+
```
78+
79+
### PSCustomObject
80+
81+
A simple PSCustomObject by @brettmillerb. It has 4 properties that you can tab through to quickly fill in.
82+
83+
#### Snippet
84+
85+
```json
86+
"PSCustomObject": {
87+
"prefix": "PSCustomObject",
88+
"body": [
89+
"[PSCustomObject]@{\r",
90+
"\t${item1} = ${Property1}\r",
91+
"\t${item2} = ${Property2}\r",
92+
"\t${item3} = ${Property3}\r",
93+
"\t${item4} = ${Property4}\r",
94+
"}"
95+
],
96+
"description": "Creates a PSCustomObject"
97+
}
98+
```
99+
61100
## Contributing
62101

63102
If you'd like to add a snippet to this list, [open a pull request](https://opensource.guide/how-to-contribute/#opening-a-pull-request) with the following changes:
@@ -80,7 +119,7 @@ An example looks like this (NOTE: all lowercase link):
80119
which will show up in the ToC like this:
81120

82121
| Table of Contents |
83-
|:-----------------:|
122+
|:------------------|
84123
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject_ |
85124

86125
### Body

0 commit comments

Comments
 (0)