Skip to content

Commit 4b628f5

Browse files
authored
Update examples to use Export-CrescendoCommand (#127)
1 parent 8bf8f7e commit 4b628f5

File tree

2 files changed

+46
-53
lines changed

2 files changed

+46
-53
lines changed

reference/docs-conceptual/Crescendo/advanced/using-crescendo-cmdlets.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: This article provides examples for using the Crescendo cmdlets to create a configuration. This can be used as an alternate for manually created the JSON configuration file.
3-
ms.date: 05/20/2022
3+
ms.date: 12/14/2022
44
title: Create a Crescendo configuration using the Crescendo cmdlets
55
---
66
# Create a Crescendo configuration using the Crescendo cmdlets
@@ -85,11 +85,8 @@ configuration to create a new PowerShell module. For a detailed explanation of t
8585
Handlers, see [this series of posts][blog] on the **PowerShell Community** blog.
8686

8787
```powershell
88-
# Create an empty configuration object
89-
$NewConfiguration = [ordered]@{
90-
'$schema' = 'https://aka.ms/PowerShell/Crescendo/Schemas/2021-11'
91-
Commands = @()
92-
}
88+
# Create an empty array for Command object
89+
$CrescendoCommands = @()
9390
9491
## Create first Crescendo command and set its properties
9592
$cmdlet = @{
@@ -119,7 +116,7 @@ $handler.Handler = 'ParseProvider'
119116
$newCommand.OutputHandlers += $handler
120117
121118
## Add the command to the Commands collection of the configuration
122-
$NewConfiguration.Commands += $newCommand
119+
$CrescendoCommands += $newCommand
123120
124121
## Create second Crescendo command and set its properties
125122
$cmdlet = @{
@@ -194,10 +191,10 @@ $handler.Handler = 'ParseShadow'
194191
$newCommand.OutputHandlers += $handler
195192
196193
## Add the command to the Commands collection of the configuration
197-
$NewConfiguration.Commands += $newCommand
194+
$CrescendoCommands += $newCommand
198195
199196
# Export the configuration to a JSON file and create the module
200-
$NewConfiguration | ConvertTo-Json -Depth 5 | Out-File .\vssadmin.json -Force
197+
Export-CrescendoCommand -command $CrescendoCommands -fileName .\vssadmin.json
201198
Export-CrescendoModule -ConfigurationFile vssadmin.json -ModuleName .\vssadmin.psm1 -Force
202199
```
203200

reference/docs-conceptual/Crescendo/get-started/create-new-cmdlet.md

+40-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: How to create a Crescendo cmdlet.
3-
ms.date: 03/09/2022
3+
ms.date: 12/14/2022
44
title: Create a Crescendo cmdlet
55
---
66
# Create a Crescendo cmdlet
@@ -79,17 +79,13 @@ OutputHandlers :
7979
The following example shows how to create a new configuration file.
8080

8181
```powershell
82-
$NewConfiguration = @{
83-
'$schema' = 'https://aka.ms/PowerShell/Crescendo/Schemas/2021-11'
84-
Commands = @()
85-
}
8682
$parameters = @{
8783
Verb = 'Show'
8884
Noun = 'AzCmAgent'
8985
OriginalName = "c:/program files/AzureConnectedMachineAgent/azcmagent.exe"
9086
}
91-
$NewConfiguration.Commands += New-CrescendoCommand @parameters
92-
$NewConfiguration | ConvertTo-Json -Depth 3 | Out-File .\AzCmAgent.json
87+
$CrescendoCommands += New-CrescendoCommand @parameters
88+
Export-CrescendoCommand -command $CrescendoCommands -fileName .\AzCmAgent.json
9389
```
9490

9591
Crescendo configuration file has a JSON schema and can contain one or more cmdlet definitions in an
@@ -100,32 +96,22 @@ an array to contain the cmdlet definitions. The output from `New-CrescendoComman
10096

10197
```json
10298
{
103-
"$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2021-11",
99+
"$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2022-06",
104100
"Commands": [
105101
{
106102
"Verb": "Show",
107103
"Noun": "AzCmAgent",
108104
"OriginalName": "c:/program files/AzureConnectedMachineAgent/azcmagent.exe",
109-
"OriginalCommandElements": null,
110105
"Platform": [
111106
"Windows",
112107
"Linux",
113108
"MacOS"
114109
],
115-
"Elevation": null,
116-
"Aliases": null,
117-
"DefaultParameterSetName": null,
118110
"SupportsShouldProcess": false,
119-
"ConfirmImpact": null,
120111
"SupportsTransactions": false,
121112
"NoInvocation": false,
122-
"Description": null,
123-
"Usage": null,
124113
"Parameters": [],
125-
"Examples": [],
126-
"OriginalText": null,
127-
"HelpLinks": null,
128-
"OutputHandlers": null
114+
"Examples": []
129115
}
130116
]
131117
}
@@ -159,32 +145,37 @@ The following example shows the full JSON definition of the new cmdlet after add
159145

160146
```json
161147
{
162-
"$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2021-11",
163-
"Commands": [
148+
"$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2022-06",
149+
"Commands": [
150+
{
151+
"Verb": "Show",
152+
"Noun": "AzCmAgent",
153+
"OriginalName": "c:/program files/AzureConnectedMachineAgent/azcmagent.exe",
154+
"OriginalCommandElements": [
155+
"show",
156+
"--json"
157+
],
158+
"Platform": [
159+
"Windows",
160+
],
161+
"Description": "Gets machine metadata and Agent status. This is primarily useful for troubleshooting.",
162+
"Aliases": [
163+
"azinfo"
164+
],
165+
"OutputHandlers": [
164166
{
165-
"Verb": "Show",
166-
"Noun": "AzCmAgent",
167-
"Platform": [
168-
"Windows"
169-
],
170-
"OriginalName": "c:/program files/AzureConnectedMachineAgent/azcmagent.exe",
171-
"OriginalCommandElements": [
172-
"show",
173-
"--json"
174-
],
175-
"Description": "Gets machine metadata and Agent status. This is primarily useful for troubleshooting.",
176-
"Aliases": [
177-
"azinfo"
178-
],
179-
"OutputHandlers": [
180-
{
181-
"ParameterSetName": "Default",
182-
"HandlerType": "Inline",
183-
"Handler": "$args[0] | ConvertFrom-Json"
184-
}
185-
]
167+
"ParameterSetName": "Default",
168+
"HandlerType": "Inline",
169+
"Handler": "$args[0] | ConvertFrom-Json"
186170
}
187-
]
171+
],
172+
"SupportsShouldProcess": false,
173+
"SupportsTransactions": false,
174+
"NoInvocation": false,
175+
"Parameters": [],
176+
"Examples": []
177+
}
178+
]
188179
}
189180
```
190181

@@ -241,7 +232,12 @@ definition in a new JSON file or add it to the **Commands** array of the previou
241232
"HandlerType": "Inline",
242233
"Handler": "$args[0] | ConvertFrom-Json"
243234
}
244-
]
235+
],
236+
"SupportsShouldProcess": false,
237+
"SupportsTransactions": false,
238+
"NoInvocation": false,
239+
"Parameters": [],
240+
"Examples": []
245241
}
246242
```
247243

0 commit comments

Comments
 (0)