File tree Expand file tree Collapse file tree 3 files changed +81
-3
lines changed Expand file tree Collapse file tree 3 files changed +81
-3
lines changed Original file line number Diff line number Diff line change 1
- - Add ` AsValue ` parameter to ` Export-ServiceNowAttachment ` to return attachment contents instead of writing to a file
1
+ - Add ` AsValue ` parameter to ` Get-ServiceNowRecord ` to return the underlying value for a property instead of a pscustomobject. Get your sys_id directly!
2
+ - Add formatting for Unique Certificate (cmdb_ci_certificate) table
Original file line number Diff line number Diff line change 49
49
For instance, an RITM may have custom variables, but the associated tasks may not.
50
50
A property named 'CustomVariable' will be added to the return object.
51
51
52
+ . PARAMETER AsValue
53
+ Return the underlying value instead of pscustomobject.
54
+ Only valid when the Property parameter is set to 1 item.
55
+ Helpful when retrieving sys_id for example.
56
+
52
57
. PARAMETER Connection
53
58
Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
54
59
105
110
Get-ServiceNowRecord -Table 'change request' -IncludeCustomVariable -First 5
106
111
Get the first 5 change requests and retrieve custom variable info
107
112
113
+ . EXAMPLE
114
+ Get-ServiceNowRecord -Table 'cmdb_ci' -Property sys_id -First 1 -AsValue
115
+ Get the underlying value for a property instead of a pscustomobject where the value needs to be extracted
116
+
108
117
. EXAMPLE
109
118
gsnr RITM0010001
110
119
Get a specific record by number using the function alias
@@ -175,6 +184,9 @@ function Get-ServiceNowRecord {
175
184
[Parameter ()]
176
185
[switch ] $IncludeCustomVariable ,
177
186
187
+ [Parameter ()]
188
+ [switch ] $AsValue ,
189
+
178
190
[Parameter ()]
179
191
[hashtable ] $Connection ,
180
192
@@ -336,12 +348,20 @@ function Get-ServiceNowRecord {
336
348
else {
337
349
338
350
# format the results
339
- if ( -not $Property ) {
351
+ if ( $Property ) {
352
+ if ( $Property.Count -eq 1 -and $AsValue ) {
353
+ $result | Select-Object - ExpandProperty $result.PSObject.Properties.Name
354
+ }
355
+ else {
356
+ $result
357
+ }
358
+ }
359
+ else {
340
360
if ($thisTable.Type ) {
341
361
$result | ForEach-Object { $_.PSObject.TypeNames.Insert (0 , $thisTable.Type ) }
342
362
}
363
+ $result
343
364
}
344
- $result
345
365
}
346
366
}
347
367
}
Original file line number Diff line number Diff line change 472
472
</TableRowEntries >
473
473
</TableControl >
474
474
</View >
475
+ <View >
476
+ <Name >ServiceNow.UniqueCertificate</Name >
477
+ <ViewSelectedBy >
478
+ <TypeName >ServiceNow.UniqueCertificate</TypeName >
479
+ </ViewSelectedBy >
480
+ <TableControl >
481
+ <TableHeaders >
482
+ <TableColumnHeader >
483
+ <Label >name</Label >
484
+ <Width >30</Width >
485
+ </TableColumnHeader >
486
+ <TableColumnHeader >
487
+ <Label >valid_to</Label >
488
+ <Width >20</Width >
489
+ </TableColumnHeader >
490
+ <TableColumnHeader >
491
+ <Label >state</Label >
492
+ <Width >15</Width >
493
+ </TableColumnHeader >
494
+ <TableColumnHeader >
495
+ <Label >issuer</Label >
496
+ <Width >30</Width >
497
+ </TableColumnHeader >
498
+ <TableColumnHeader >
499
+ <Label >sys_id</Label >
500
+ <Width >32</Width >
501
+ </TableColumnHeader >
502
+ </TableHeaders >
503
+ <TableRowEntries >
504
+ <TableRowEntry >
505
+ <TableColumnItems >
506
+ <TableColumnItem >
507
+ <PropertyName >name</PropertyName >
508
+ </TableColumnItem >
509
+ <TableColumnItem >
510
+ <PropertyName >valid_to</PropertyName >
511
+ </TableColumnItem >
512
+ <TableColumnItem >
513
+ <PropertyName >state</PropertyName >
514
+ </TableColumnItem >
515
+ <TableColumnItem >
516
+ <ScriptBlock >
517
+ if ($_.issuer.display_value) {
518
+ $_.issuer.display_value
519
+ } else {
520
+ $_.issuer.value
521
+ }
522
+ </ScriptBlock >
523
+ </TableColumnItem >
524
+ <TableColumnItem >
525
+ <PropertyName >sys_id</PropertyName >
526
+ </TableColumnItem >
527
+ </TableColumnItems >
528
+ </TableRowEntry >
529
+ </TableRowEntries >
530
+ </TableControl >
531
+ </View >
475
532
</ViewDefinitions >
476
533
</Configuration >
You can’t perform that action at this time.
0 commit comments