Skip to content

Commit 6bbb856

Browse files
committed
Apply 'lean' parameter standardization to all Get functions
1 parent f3b4791 commit 6bbb856

9 files changed

+193
-313
lines changed

ServiceNow/Public/Get-ServiceNowChangeRequest.ps1

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,46 @@
11
function Get-ServiceNowChangeRequest {
2-
param(
2+
[OutputType([System.Management.Automation.PSCustomObject])]
3+
[CmdletBinding(DefaultParameterSetName)]
4+
Param(
35
# Machine name of the field to order by
4-
[parameter(mandatory=$false)]
5-
[parameter(ParameterSetName='SpecifyConnectionFields')]
6-
[parameter(ParameterSetName='UseConnectionObject')]
7-
[parameter(ParameterSetName='SetGlobalAuth')]
8-
[string]$OrderBy='opened_at',
6+
[Parameter(Mandatory = $false)]
7+
[string]$OrderBy = 'opened_at',
98

109
# Direction of ordering (Desc/Asc)
11-
[parameter(mandatory=$false)]
12-
[parameter(ParameterSetName='SpecifyConnectionFields')]
13-
[parameter(ParameterSetName='UseConnectionObject')]
14-
[parameter(ParameterSetName='SetGlobalAuth')]
15-
[ValidateSet("Desc", "Asc")]
16-
[string]$OrderDirection='Desc',
10+
[Parameter(Mandatory = $false)]
11+
[ValidateSet('Desc', 'Asc')]
12+
[string]$OrderDirection = 'Desc',
1713

1814
# Maximum number of records to return
19-
[parameter(mandatory=$false)]
20-
[parameter(ParameterSetName='SpecifyConnectionFields')]
21-
[parameter(ParameterSetName='UseConnectionObject')]
22-
[parameter(ParameterSetName='SetGlobalAuth')]
23-
[int]$Limit=10,
15+
[Parameter(Mandatory = $false)]
16+
[int]$Limit = 10,
2417

2518
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
26-
[parameter(mandatory=$false)]
27-
[parameter(ParameterSetName='SpecifyConnectionFields')]
28-
[parameter(ParameterSetName='UseConnectionObject')]
29-
[parameter(ParameterSetName='SetGlobalAuth')]
30-
[hashtable]$MatchExact=@{},
19+
[Parameter(Mandatory = $false)]
20+
[hashtable]$MatchExact = @{},
3121

3222
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
33-
[parameter(mandatory=$false)]
34-
[parameter(ParameterSetName='SpecifyConnectionFields')]
35-
[parameter(ParameterSetName='UseConnectionObject')]
36-
[parameter(ParameterSetName='SetGlobalAuth')]
37-
[hashtable]$MatchContains=@{},
23+
[Parameter(Mandatory = $false)]
24+
[hashtable]$MatchContains = @{},
3825

39-
# Whether to return manipulated display values rather than actual database values.
40-
[parameter(mandatory=$false)]
41-
[parameter(ParameterSetName='SpecifyConnectionFields')]
42-
[parameter(ParameterSetName='UseConnectionObject')]
43-
[parameter(ParameterSetName='SetGlobalAuth')]
44-
[ValidateSet("true","false", "all")]
45-
[string]$DisplayValues='true',
26+
# Whether or not to show human readable display values instead of machine values
27+
[Parameter(Mandatory = $false)]
28+
[ValidateSet('true', 'false', 'all')]
29+
[string]$DisplayValues = 'true',
4630

47-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
31+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
4832
[ValidateNotNullOrEmpty()]
49-
[PSCredential]
50-
$ServiceNowCredential,
33+
[Alias('ServiceNowCredential')]
34+
[PSCredential]$Credential,
5135

52-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
53-
[ValidateNotNullOrEmpty()]
54-
[string]
55-
$ServiceNowURL,
36+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
37+
[ValidateScript({Test-ServiceNowURL -Url $_})]
38+
[Alias('Url')]
39+
[string]$ServiceNowURL,
5640

57-
[Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)]
41+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $true)]
5842
[ValidateNotNullOrEmpty()]
59-
[Hashtable]
60-
$Connection
43+
[hashtable]$Connection
6144
)
6245

6346
# Query Splat

ServiceNow/Public/Get-ServiceNowConfigurationItem.ps1

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,46 @@
11
function Get-ServiceNowConfigurationItem {
2-
param(
2+
[OutputType([System.Management.Automation.PSCustomObject])]
3+
[CmdletBinding(DefaultParameterSetName)]
4+
Param(
35
# Machine name of the field to order by
4-
[parameter(mandatory=$false)]
5-
[parameter(ParameterSetName='SpecifyConnectionFields')]
6-
[parameter(ParameterSetName='UseConnectionObject')]
7-
[parameter(ParameterSetName='SetGlobalAuth')]
8-
[string]$OrderBy='name',
6+
[Parameter(Mandatory = $false)]
7+
[string]$OrderBy = 'name',
98

109
# Direction of ordering (Desc/Asc)
11-
[parameter(mandatory=$false)]
12-
[parameter(ParameterSetName='SpecifyConnectionFields')]
13-
[parameter(ParameterSetName='UseConnectionObject')]
14-
[parameter(ParameterSetName='SetGlobalAuth')]
15-
[ValidateSet("Desc", "Asc")]
16-
[string]$OrderDirection='Desc',
10+
[Parameter(Mandatory = $false)]
11+
[ValidateSet('Desc', 'Asc')]
12+
[string]$OrderDirection = 'Desc',
1713

1814
# Maximum number of records to return
19-
[parameter(mandatory=$false)]
20-
[parameter(ParameterSetName='SpecifyConnectionFields')]
21-
[parameter(ParameterSetName='UseConnectionObject')]
22-
[parameter(ParameterSetName='SetGlobalAuth')]
23-
[int]$Limit=10,
15+
[Parameter(Mandatory = $false)]
16+
[int]$Limit = 10,
2417

2518
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
26-
[parameter(mandatory=$false)]
27-
[parameter(ParameterSetName='SpecifyConnectionFields')]
28-
[parameter(ParameterSetName='UseConnectionObject')]
29-
[parameter(ParameterSetName='SetGlobalAuth')]
30-
[hashtable]$MatchExact=@{},
19+
[Parameter(Mandatory = $false)]
20+
[hashtable]$MatchExact = @{},
3121

3222
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
33-
[parameter(mandatory=$false)]
34-
[parameter(ParameterSetName='SpecifyConnectionFields')]
35-
[parameter(ParameterSetName='UseConnectionObject')]
36-
[parameter(ParameterSetName='SetGlobalAuth')]
37-
[hashtable]$MatchContains=@{},
23+
[Parameter(Mandatory = $false)]
24+
[hashtable]$MatchContains = @{},
3825

39-
# Whether to return manipulated display values rather than actual database values.
40-
[parameter(mandatory=$false)]
41-
[parameter(ParameterSetName='SpecifyConnectionFields')]
42-
[parameter(ParameterSetName='UseConnectionObject')]
43-
[parameter(ParameterSetName='SetGlobalAuth')]
44-
[ValidateSet("true","false", "all")]
45-
[string]$DisplayValues='true',
26+
# Whether or not to show human readable display values instead of machine values
27+
[Parameter(Mandatory = $false)]
28+
[ValidateSet('true', 'false', 'all')]
29+
[string]$DisplayValues = 'true',
4630

47-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
31+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
4832
[ValidateNotNullOrEmpty()]
49-
[PSCredential]
50-
$ServiceNowCredential,
33+
[Alias('ServiceNowCredential')]
34+
[PSCredential]$Credential,
5135

52-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
53-
[ValidateNotNullOrEmpty()]
54-
[string]
55-
$ServiceNowURL,
36+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
37+
[ValidateScript({Test-ServiceNowURL -Url $_})]
38+
[Alias('Url')]
39+
[string]$ServiceNowURL,
5640

57-
[Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)]
41+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $true)]
5842
[ValidateNotNullOrEmpty()]
59-
[Hashtable]
60-
$Connection
43+
[hashtable]$Connection
6144
)
6245

6346
# Query Splat

ServiceNow/Public/Get-ServiceNowIncident.ps1

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,46 @@
11
function Get-ServiceNowIncident{
2-
param(
2+
[OutputType([System.Management.Automation.PSCustomObject])]
3+
[CmdletBinding(DefaultParameterSetName)]
4+
Param(
35
# Machine name of the field to order by
4-
[parameter(mandatory=$false)]
5-
[parameter(ParameterSetName='SpecifyConnectionFields')]
6-
[parameter(ParameterSetName='UseConnectionObject')]
7-
[parameter(ParameterSetName='SetGlobalAuth')]
8-
[string]$OrderBy='opened_at',
6+
[Parameter(Mandatory = $false)]
7+
[string]$OrderBy = 'opened_at',
98

109
# Direction of ordering (Desc/Asc)
11-
[parameter(mandatory=$false)]
12-
[parameter(ParameterSetName='SpecifyConnectionFields')]
13-
[parameter(ParameterSetName='UseConnectionObject')]
14-
[parameter(ParameterSetName='SetGlobalAuth')]
15-
[ValidateSet("Desc", "Asc")]
16-
[string]$OrderDirection='Desc',
10+
[Parameter(Mandatory = $false)]
11+
[ValidateSet('Desc', 'Asc')]
12+
[string]$OrderDirection = 'Desc',
1713

1814
# Maximum number of records to return
19-
[parameter(mandatory=$false)]
20-
[parameter(ParameterSetName='SpecifyConnectionFields')]
21-
[parameter(ParameterSetName='UseConnectionObject')]
22-
[parameter(ParameterSetName='SetGlobalAuth')]
23-
[int]$Limit=10,
15+
[Parameter(Mandatory = $false)]
16+
[int]$Limit = 10,
2417

2518
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
26-
[parameter(mandatory=$false)]
27-
[parameter(ParameterSetName='SpecifyConnectionFields')]
28-
[parameter(ParameterSetName='UseConnectionObject')]
29-
[parameter(ParameterSetName='SetGlobalAuth')]
30-
[hashtable]$MatchExact=@{},
19+
[Parameter(Mandatory = $false)]
20+
[hashtable]$MatchExact = @{},
3121

3222
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
33-
[parameter(mandatory=$false)]
34-
[parameter(ParameterSetName='SpecifyConnectionFields')]
35-
[parameter(ParameterSetName='UseConnectionObject')]
36-
[parameter(ParameterSetName='SetGlobalAuth')]
37-
[hashtable]$MatchContains=@{},
23+
[Parameter(Mandatory = $false)]
24+
[hashtable]$MatchContains = @{},
3825

39-
# Whether to return manipulated display values rather than actual database values.
40-
[parameter(mandatory=$false)]
41-
[parameter(ParameterSetName='SpecifyConnectionFields')]
42-
[parameter(ParameterSetName='UseConnectionObject')]
43-
[parameter(ParameterSetName='SetGlobalAuth')]
44-
[ValidateSet("true","false", "all")]
45-
[string]$DisplayValues='true',
26+
# Whether or not to show human readable display values instead of machine values
27+
[Parameter(Mandatory = $false)]
28+
[ValidateSet('true', 'false', 'all')]
29+
[string]$DisplayValues = 'true',
4630

47-
# Credential used to authenticate to ServiceNow
48-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
31+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
4932
[ValidateNotNullOrEmpty()]
50-
[PSCredential]
51-
$ServiceNowCredential,
33+
[Alias('ServiceNowCredential')]
34+
[PSCredential]$Credential,
5235

53-
# The URL for the ServiceNow instance being used
54-
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
55-
[ValidateNotNullOrEmpty()]
56-
[string]
57-
$ServiceNowURL,
36+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
37+
[ValidateScript({Test-ServiceNowURL -Url $_})]
38+
[Alias('Url')]
39+
[string]$ServiceNowURL,
5840

59-
#Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
60-
[Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)]
41+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $true)]
6142
[ValidateNotNullOrEmpty()]
62-
[Hashtable]
63-
$Connection
43+
[hashtable]$Connection
6444
)
6545

6646
# Query Splat

ServiceNow/Public/Get-ServiceNowRequest.ps1

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,48 @@
11
function Get-ServiceNowRequest {
2-
param(
2+
[OutputType([System.Management.Automation.PSCustomObject])]
3+
[CmdletBinding(DefaultParameterSetName)]
4+
Param(
35
# Machine name of the field to order by
4-
[parameter(mandatory = $false)]
5-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
6-
[parameter(ParameterSetName = 'UseConnectionObject')]
7-
[parameter(ParameterSetName = 'SetGlobalAuth')]
6+
[Parameter(Mandatory = $false)]
87
[string]$OrderBy = 'opened_at',
9-
8+
109
# Direction of ordering (Desc/Asc)
11-
[parameter(mandatory = $false)]
12-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
13-
[parameter(ParameterSetName = 'UseConnectionObject')]
14-
[parameter(ParameterSetName = 'SetGlobalAuth')]
15-
[ValidateSet("Desc", "Asc")]
10+
[Parameter(Mandatory = $false)]
11+
[ValidateSet('Desc', 'Asc')]
1612
[string]$OrderDirection = 'Desc',
1713

1814
# Maximum number of records to return
19-
[parameter(mandatory = $false)]
20-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
21-
[parameter(ParameterSetName = 'UseConnectionObject')]
22-
[parameter(ParameterSetName = 'SetGlobalAuth')]
15+
[Parameter(Mandatory = $false)]
2316
[int]$Limit = 10,
24-
17+
2518
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
26-
[parameter(mandatory = $false)]
27-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
28-
[parameter(ParameterSetName = 'UseConnectionObject')]
29-
[parameter(ParameterSetName = 'SetGlobalAuth')]
19+
[Parameter(Mandatory = $false)]
3020
[hashtable]$MatchExact = @{},
3121

3222
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
33-
[parameter(mandatory = $false)]
34-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
35-
[parameter(ParameterSetName = 'UseConnectionObject')]
36-
[parameter(ParameterSetName = 'SetGlobalAuth')]
23+
[Parameter(Mandatory = $false)]
3724
[hashtable]$MatchContains = @{},
3825

3926
# Whether or not to show human readable display values instead of machine values
40-
[parameter(mandatory = $false)]
41-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
42-
[parameter(ParameterSetName = 'UseConnectionObject')]
43-
[parameter(ParameterSetName = 'SetGlobalAuth')]
44-
[ValidateSet("true", "false", "all")]
27+
[Parameter(Mandatory = $false)]
28+
[ValidateSet('true', 'false', 'all')]
4529
[string]$DisplayValues = 'true',
4630

47-
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
31+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
4832
[ValidateNotNullOrEmpty()]
49-
[PSCredential]
50-
$ServiceNowCredential,
33+
[Alias('ServiceNowCredential')]
34+
[PSCredential]$Credential,
5135

52-
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
53-
[ValidateNotNullOrEmpty()]
54-
[string]
55-
$ServiceNowURL,
36+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)]
37+
[ValidateScript({Test-ServiceNowURL -Url $_})]
38+
[Alias('Url')]
39+
[string]$ServiceNowURL,
5640

57-
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
41+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $true)]
5842
[ValidateNotNullOrEmpty()]
59-
[Hashtable]
60-
$Connection
43+
[hashtable]$Connection
6144
)
62-
45+
6346
# Query Splat
6447
$newServiceNowQuerySplat = @{
6548
OrderBy = $OrderBy
@@ -68,7 +51,7 @@ function Get-ServiceNowRequest {
6851
MatchContains = $MatchContains
6952
}
7053
$Query = New-ServiceNowQuery @newServiceNowQuerySplat
71-
54+
7255
# Table Splat
7356
$getServiceNowTableSplat = @{
7457
Table = 'sc_request'
@@ -78,7 +61,7 @@ function Get-ServiceNowRequest {
7861
}
7962

8063
# Update the Table Splat if the parameters have values
81-
if ($null -ne $PSBoundParameters.Connection) {
64+
if ($null -ne $PSBoundParameters.Connection) {
8265
$getServiceNowTableSplat.Add('Connection', $Connection)
8366
}
8467
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {

0 commit comments

Comments
 (0)