Skip to content

Commit 2ca3db3

Browse files
authored
Merge pull request #67 from replicaJunction/feature-fields
Feature: specify fields to return
2 parents 348c3a6 + 8e9fc9c commit 2ca3db3

9 files changed

+49
-1
lines changed

ServiceNow/Public/Get-ServiceNowChangeRequest.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowChangeRequest {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -56,7 +60,8 @@ function Get-ServiceNowChangeRequest {
5660
$getServiceNowTableSplat = @{
5761
Table = 'change_request'
5862
Query = $Query
59-
Limit = $Limit
63+
Limit = $
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

ServiceNow/Public/Get-ServiceNowConfigurationItem.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowConfigurationItem {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -57,6 +61,7 @@ function Get-ServiceNowConfigurationItem {
5761
Table = 'cmdb_ci'
5862
Query = $Query
5963
Limit = $Limit
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

ServiceNow/Public/Get-ServiceNowIncident.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowIncident{
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -57,6 +61,7 @@ function Get-ServiceNowIncident{
5761
Table = 'incident'
5862
Query = $Query
5963
Limit = $Limit
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

ServiceNow/Public/Get-ServiceNowRequest.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowRequest {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -57,6 +61,7 @@ function Get-ServiceNowRequest {
5761
Table = 'sc_request'
5862
Query = $Query
5963
Limit = $Limit
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

ServiceNow/Public/Get-ServiceNowRequestItem.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function Get-ServiceNowRequestItem {
3131
[parameter(Mandatory = $false)]
3232
[int]$Limit = 10,
3333

34+
# Fields to return
35+
[parameter(mandatory = $false)]
36+
[string[]]$Fields,
37+
3438
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
3539
[parameter(Mandatory = $false)]
3640
[hashtable]$MatchExact = @{},
@@ -72,6 +76,7 @@ function Get-ServiceNowRequestItem {
7276
Table = 'sc_req_item'
7377
Query = $Query
7478
Limit = $Limit
79+
Fields = $Fields
7580
DisplayValues = $DisplayValues
7681
}
7782

ServiceNow/Public/Get-ServiceNowTable.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ function Get-ServiceNowTable {
2929
[Parameter(Mandatory = $false)]
3030
[int]$Limit = 10,
3131

32+
# Fields to return
33+
[parameter(mandatory = $false)]
34+
[string[]]$Fields,
35+
3236
# Whether or not to show human readable display values instead of machine values
3337
[Parameter(Mandatory = $false)]
3438
[ValidateSet('true', 'false', 'all')]
@@ -73,6 +77,10 @@ function Get-ServiceNowTable {
7377
$Body.sysparm_query = $Query
7478
}
7579

80+
if ($Fields) {
81+
$Body.sysparm_fields = $Fields -join ','
82+
}
83+
7684
# Perform table query and capture results
7785
$Uri = $ServiceNowURL + "/table/$Table"
7886
$Result = (Invoke-RestMethod -Uri $Uri -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").Result

ServiceNow/Public/Get-ServiceNowTableEntry.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ function Get-ServiceNowTableEntry {
3838
[parameter(Mandatory = $false)]
3939
[int]$Limit = 10,
4040

41+
# Fields to return
42+
[parameter(mandatory = $false)]
43+
[string[]]$Fields,
44+
4145
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
4246
[parameter(Mandatory = $false)]
4347
[hashtable]$MatchExact = @{},
@@ -82,6 +86,7 @@ function Get-ServiceNowTableEntry {
8286
Table = $Table
8387
Query = $Query
8488
Limit = $Limit
89+
Fields = $Fields
8590
DisplayValues = $DisplayValues
8691
ErrorAction = 'Stop'
8792
}

ServiceNow/Public/Get-ServiceNowUser.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowUser{
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -57,6 +61,7 @@ function Get-ServiceNowUser{
5761
Table = 'sys_user'
5862
Query = $Query
5963
Limit = $Limit
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

ServiceNow/Public/Get-ServiceNowUserGroup.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function Get-ServiceNowUserGroup{
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[parameter(mandatory = $false)]
20+
[string[]]$Fields,
21+
1822
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1923
[Parameter(Mandatory = $false)]
2024
[hashtable]$MatchExact = @{},
@@ -57,6 +61,7 @@ function Get-ServiceNowUserGroup{
5761
Table = 'sys_user_group'
5862
Query = $Query
5963
Limit = $Limit
64+
Fields = $Fields
6065
DisplayValues = $DisplayValues
6166
}
6267

0 commit comments

Comments
 (0)