|
1 | 1 | 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)] |
2 | 20 | param( |
3 | 21 | # 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)] |
8 | 23 | [string]$OrderBy = 'opened_at', |
9 | 24 |
|
10 | 25 | # 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')] |
16 | 28 | [string]$OrderDirection = 'Desc', |
17 | 29 |
|
18 | 30 | # 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)] |
23 | 32 | [int]$Limit = 10, |
24 | 33 |
|
25 | 34 | # 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)] |
30 | 36 | [hashtable]$MatchExact = @{}, |
31 | 37 |
|
32 | 38 | # 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)] |
37 | 40 | [hashtable]$MatchContains = @{}, |
38 | 41 |
|
39 | 42 | # 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')] |
45 | 45 | [string]$DisplayValues = 'true', |
46 | 46 |
|
47 | 47 | [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)] |
48 | 48 | [ValidateNotNullOrEmpty()] |
49 | | - [PSCredential] |
50 | | - $ServiceNowCredential, |
| 49 | + [Alias('ServiceNowCredential')] |
| 50 | + [PSCredential]$Credential, |
51 | 51 |
|
52 | 52 | [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)] |
53 | 53 | [ValidateNotNullOrEmpty()] |
54 | | - [string] |
55 | | - $ServiceNowURL, |
| 54 | + [string]$ServiceNowURL, |
56 | 55 |
|
57 | 56 | [Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)] |
58 | 57 | [ValidateNotNullOrEmpty()] |
59 | | - [Hashtable] |
60 | | - $Connection |
| 58 | + [hashtable]$Connection |
61 | 59 | ) |
62 | 60 |
|
63 | 61 | # Query Splat |
@@ -88,6 +86,6 @@ function Get-ServiceNowRequestItem { |
88 | 86 |
|
89 | 87 | # Perform query and return each object in the format.ps1xml format |
90 | 88 | $Result = Get-ServiceNowTable @getServiceNowTableSplat |
91 | | - $Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0, "ServiceNow.RequestItem")} |
| 89 | + $Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0,'ServiceNow.Request')} |
92 | 90 | $Result |
93 | 91 | } |
0 commit comments