Skip to content

Commit 2c6b836

Browse files
committed
Added help, used lean params, set format to existing option
1 parent 04173af commit 2c6b836

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed
Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,61 @@
11
function Get-ServiceNowRequestItem {
2+
<#
3+
.SYNOPSIS
4+
Query for Request Item (RITM) tickets.
5+
6+
.DESCRIPTION
7+
Query for Request Item (RITM) tickets from the sc_req_item table.
8+
9+
.EXAMPLE
10+
Get-ServiceNowRequestItem -MatchExact @{number='RITM0000001'}
11+
12+
Return the details for RITM0000001
13+
14+
.OUTPUTS
15+
System.Management.Automation.PSCustomObject
16+
#>
17+
18+
[OutputType([System.Management.Automation.PSCustomObject])]
19+
[CmdletBinding(DefaultParameterSetName)]
220
param(
321
# Machine name of the field to order by
4-
[parameter(mandatory = $false)]
5-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
6-
[parameter(ParameterSetName = 'UseConnectionObject')]
7-
[parameter(ParameterSetName = 'SetGlobalAuth')]
22+
[parameter(Mandatory = $false)]
823
[string]$OrderBy = 'opened_at',
924

1025
# 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")]
26+
[parameter(Mandatory = $false)]
27+
[ValidateSet('Desc', 'Asc')]
1628
[string]$OrderDirection = 'Desc',
1729

1830
# Maximum number of records to return
19-
[parameter(mandatory = $false)]
20-
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
21-
[parameter(ParameterSetName = 'UseConnectionObject')]
22-
[parameter(ParameterSetName = 'SetGlobalAuth')]
31+
[parameter(Mandatory = $false)]
2332
[int]$Limit = 10,
2433

2534
# 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')]
35+
[parameter(Mandatory = $false)]
3036
[hashtable]$MatchExact = @{},
3137

3238
# 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')]
39+
[parameter(Mandatory = $false)]
3740
[hashtable]$MatchContains = @{},
3841

3942
# 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")]
43+
[parameter(Mandatory = $false)]
44+
[ValidateSet('true', 'false', 'all')]
4545
[string]$DisplayValues = 'true',
4646

4747
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
4848
[ValidateNotNullOrEmpty()]
49-
[PSCredential]
50-
$ServiceNowCredential,
49+
[Alias('ServiceNowCredential')]
50+
[PSCredential]$Credential,
5151

5252
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
5353
[ValidateNotNullOrEmpty()]
54-
[string]
55-
$ServiceNowURL,
54+
[string]$ServiceNowURL,
5655

5756
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
5857
[ValidateNotNullOrEmpty()]
59-
[Hashtable]
60-
$Connection
58+
[hashtable]$Connection
6159
)
6260

6361
# Query Splat
@@ -88,6 +86,6 @@ function Get-ServiceNowRequestItem {
8886

8987
# Perform query and return each object in the format.ps1xml format
9088
$Result = Get-ServiceNowTable @getServiceNowTableSplat
91-
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0, "ServiceNow.RequestItem")}
89+
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0,'ServiceNow.Request')}
9290
$Result
9391
}

0 commit comments

Comments
 (0)