@@ -180,18 +180,18 @@ namespace Microsoft.Azure.Commands.Profile.Models
180
180
181
181
// code omitted for brevity
182
182
183
- [Ps1Xml (Label = " Subscription Id " , Target = ViewControl .Table )]
183
+ [Ps1Xml (Label = " SubscriptionId " , Target = ViewControl .Table )]
184
184
public string Id { get ; set ; }
185
185
186
- [Ps1Xml (Label = " Subscription Name" , Target = ViewControl .Table )]
186
+ [Ps1Xml (Label = " Name" , Target = ViewControl .Table )]
187
187
public string Name { get ; set ; }
188
188
189
189
[Ps1Xml (Label = " State" , Target = ViewControl .Table )]
190
190
public string State { get ; set ; }
191
191
192
192
public string SubscriptionId { get { return Id ; } }
193
193
194
- [Ps1Xml (Label = " Tenant Id " , Target = ViewControl .Table )]
194
+ [Ps1Xml (Label = " TenantId " , Target = ViewControl .Table )]
195
195
public string TenantId
196
196
{
197
197
get
@@ -260,8 +260,8 @@ To specify what goes into the table view - use the **ScriptBlock** attribute pro
260
260
{
261
261
// code omitted for brevity
262
262
263
- [Ps1Xml (Label = " Account Id" , Target = ViewControl .Table , ScriptBlock = " $_.Account.Id" )]
264
- [Ps1Xml (Label = " Account Type" , Target = ViewControl .Table , ScriptBlock = " $_.Account.Type" )]
263
+ [Ps1Xml (Label = " Account. Id" , Target = ViewControl .Table , ScriptBlock = " $_.Account.Id" )]
264
+ [Ps1Xml (Label = " Account. Type" , Target = ViewControl .Table , ScriptBlock = " $_.Account.Type" )]
265
265
public IAzureAccount Account { get ; set ; }
266
266
267
267
// code omitted for brevity
@@ -272,8 +272,8 @@ Note: **$_** symbol in PowerShell means the same as **this** key word means in C
272
272
273
273
These two attribute will result in 2 column in the table view:
274
274
```Ps
275
- Account Id Account Type
276
- ========== ============
275
+ Account. Id Account. Type
276
+ ========== ============
277
277
```
278
278
## GroupBy a property.
279
279
@@ -284,7 +284,7 @@ public class PSAzureSubscription : IAzureSubscription
284
284
285
285
// code omitted for brevity
286
286
287
- [Ps1Xml (Label = " Subscription Id " , Target = ViewControl .Table , GroupByThis = true )]
287
+ [Ps1Xml (Label = " SubscriptionId " , Target = ViewControl .Table , GroupByThis = true )]
288
288
public string Id { get ; set ; }
289
289
290
290
// code omitted for brevity
@@ -298,7 +298,7 @@ public class PSAzureSubscription : IAzureSubscription
298
298
299
299
// code omitted for brevity
300
300
301
- [Ps1Xml (Label = " Subscription Name" , Target = ViewControl .Table , Position = 0 )]
301
+ [Ps1Xml (Label = " Name" , Target = ViewControl .Table , Position = 0 )]
302
302
public string Name { get ; set ; }
303
303
304
304
// code omitted for brevity
@@ -309,53 +309,70 @@ This will place the column at the very beginning of the table.
309
309
310
310
# How to generate format.ps1xml file.
311
311
312
- 1. First of all you need to [build ](https:// github.com/Azure/azure-powershell/blob/master/documentation/development-docs/azure-powershell-developer-guide.md#building-the-environment) PowerShell Azure:
313
-
314
- ```Powershell
315
- PS E:\git\azure-powershell> msbuild build.proj /p:SkipHelp= true
316
- ```
317
-
318
- * After the build is completed you can find build artifacts in the ```.\artifacts \Debug ``` folder :
319
-
320
- ```Powershell
321
- PS E : \git \azure - powershell > ls .\artifacts \Debug \
312
+ ## Let's consider how to generate a format.ps1xml file for the Az.Storage and Az.Account modules.
313
+ 1. Start PowerShell 6
314
+ 2. Build and import the FormatPs1XmlGenerator module.
315
+ * Go to the generator directory
316
+ ```Powershell
317
+ PS C:\Users\you> cd E:\git\azure-powershell\tools\FormatPs1XmlGenerator\
318
+ ```
319
+ * Build the generator solution
320
+ ```Powershell
321
+ PS E:\git\azure-powershell\tools\FormatPs1XmlGenerator> dotnet build
322
+ ```
323
+ * Import the generator module
324
+ ```Powershell
325
+ PS E:\git\azure-powershell\tools\FormatPs1XmlGenerator> Import-Module .\FormatPs1XmlGenerator\bin\Debug\FormatPs1XmlGenerator.psd1
326
+ ```
327
+
328
+ 3. Build the Az.Storage module.
329
+ * Go to the Storage directory
330
+ ```Powershell
331
+ PS C:\Users\you>cd E:\git\azure-powershell\src\Storage
332
+ ```
333
+ * Build the module
334
+ ```Powershell
335
+ PS E:\git\azure-powershell\src\Storage>dotnet build
336
+ ```
337
+ * Go to the repository root folder
338
+ ```Powershell
339
+ PS E:\git\azure-powershell\src\Storage>cd E:\git\azure-powershell\
340
+ ```
341
+ * Check the artifacts folder - all built modules should be there. Since Az.Storage depends on the Az.Accounts module both Az.Accounts and Az.Storage modules should be there:
342
+ ```Powershell
343
+ PS E:\git\azure-powershell> ls .\artifacts\Debug\
322
344
323
345
324
346
Directory: E:\git\azure-powershell\artifacts\Debug
325
347
326
348
327
- Mode LastWriteTime Length Name
328
- ---- ------------ - ------ ----
329
- d ---- - 4 / 25 / 2018 4 : 37 PM ResourceManager
330
- d ---- - 4 / 25 / 2018 4 : 35 PM ServiceManagement
331
- d ---- - 4 / 25 / 2018 4 : 35 PM Storage
332
- - a ---- 4 / 25 / 2018 4 : 31 PM 11384 Az .psd1
333
- - a ---- 4 / 25 / 2018 4 : 50 PM 8708 Az .psm1
334
-
335
- ```
336
-
337
- 2 . Import the ** RepoTask cmdlets ** :
338
-
339
- ```PowerShell
340
- PS E : \git \azure - powershell > Import - Module E : \git \azure - powershell \tools \RepoTasks \RepoTasks .Cmdlets \bin \Debug \RepoTasks .Cmdlets .dll
341
- ```
342
- 3 . Run the ** New - FormatPs1Xml ** cmdlet .
343
- * The cmdlet has one required argument **- ModulePath ** - a path to a module manifest (psd1 ) file . Since in our example we are using the Get - AzSubscription cmdlet from the Az .Accounts module we need to specify path to the Az .Accounts module manifest which is
344
- ```
345
- E : \git \azure - powershell \artifacts \Debug \Az .Accounts \Az .Accounts .psd1
346
- ```
347
- * Also with the cmdlet we need to use **- OnlyMarkedProperties ** switch .
348
- * You may also want to specify an output path for the generated file with the **-OutputPath** argument. If not specified this is current folder.
349
-
350
- ```
351
- PS E:\git\azure-powershell> New-FormatPs1Xml -ModulePath .\artifacts\Debug\Az.Accounts\Az.Accounts.psd1 -OnlyMarkedProperties
352
-
353
- E:\git\azure-powershell\Microsoft.Azure.Commands.Profile.generated.format.ps1xml
354
- ```
355
- * After a successful run the cmdlet outputs the full path to the generated format.ps1xml file.
349
+ Mode LastWriteTime Length Name
350
+ ---- ------------- ------ ----
351
+ d----- 1/29/2019 2:18 PM Az.Accounts
352
+ d----- 1/29/2019 2:18 PM Az.Storage
353
+ ```
354
+ 4. Run the **New-FormatPs1Xml** cmdlet.
355
+ * The cmdlet has one required parameter **-ModulePath** - a path to a module manifest (psd1) file.
356
+ * Also with the cmdlet we need to use **-OnlyMarkedProperties** switch.
357
+ * You may also want to specify an output path for the generated file with the **-OutputPath** argument. If not specified this is current folder.
358
+ * After a successful run the cmdlet outputs the full path to the generated format.ps1xml file.
359
+
360
+ * Below is an example of how to generate a format.ps1xml file for the ```Az.Storage``` module:
361
+ ```Powershell
362
+ PS E:\git\azure-powershell> New-FormatPs1Xml -OnlyMarkedProperties -ModulePath .\artifacts\Debug\Az.Storage\Az.Storage.psd1
363
+ E:\git\azure-powershell\Microsoft.Azure.PowerShell.Cmdlets.Storage.Management.generated.format.ps1xml
364
+ E:\git\azure-powershell\Microsoft.Azure.PowerShell.Cmdlets.Storage.generated.format.ps1xml
365
+ ```
366
+ * Below is an example of how to generate a format.ps1xml file for the ```Az.Account``` module:
367
+ ```powershell
368
+ PS E:\git\azure-powershell> New-FormatPs1Xml -OnlyMarkedProperties -ModulePath .\artifacts\Debug\Az.Accounts\Az.Accounts.psd1
369
+ E:\git\azure-powershell\Microsoft.Azure.PowerShell.Cmdlets.Accounts.generated.format.ps1xml
370
+ PS E:\git\azure-powershell>
371
+ ```
356
372
357
373
# How to test the format.ps1xml file.
358
374
375
+ ## Let's take a look at how to check the newly created format.ps1xml file for the ```Az.Account``` module.
359
376
**Note:** All the paths used in the example in the section are under **_azure-powershell/artifacts/Debug_**
360
377
361
378
1. **Copy** the generated format.ps1xml file to the built module folder (this is where your module manifest file psd1 is located). In our example the module folder is
@@ -396,7 +413,7 @@ PS C:\> Import-Module E:\git\azure-powershell\artifacts\Debug\Az.Accounts\Az.Acc
396
413
```Powershell
397
414
PS C:\> Get-AzSubscription
398
415
399
- Subscription Id Subscription Name State Tenant Id
416
+ SubscriptionId Name State TenantId
400
417
--------------- ----------------- ----- ---------
401
418
c9cbd920-c00c-427c-852b-c329e824c3a8 Azure SDK Powershell Test Enabled 72f988bf-86f1-41af-91ab-7a64d1d63df5
402
419
6b085460-5f21-477e-ba44-4cd9fbd030ef Azure SDK Infrastructure Enabled 72f988bf-86f1-41af-91ab-7a64d1d63df5
0 commit comments