|
1 | 1 | function Get-ServiceNowIncident{ |
2 | | - param( |
| 2 | + [OutputType([System.Management.Automation.PSCustomObject])] |
| 3 | + [CmdletBinding(DefaultParameterSetName)] |
| 4 | + Param( |
3 | 5 | # 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', |
9 | 8 |
|
10 | 9 | # 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', |
17 | 13 |
|
18 | 14 | # 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, |
24 | 17 |
|
25 | 18 | # 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 = @{}, |
31 | 21 |
|
32 | 22 | # 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 = @{}, |
38 | 25 |
|
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', |
46 | 30 |
|
47 | | - # Credential used to authenticate to ServiceNow |
48 | | - [Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)] |
| 31 | + [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $true)] |
49 | 32 | [ValidateNotNullOrEmpty()] |
50 | | - [PSCredential] |
51 | | - $ServiceNowCredential, |
| 33 | + [Alias('ServiceNowCredential')] |
| 34 | + [PSCredential]$Credential, |
52 | 35 |
|
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, |
58 | 40 |
|
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)] |
61 | 42 | [ValidateNotNullOrEmpty()] |
62 | | - [Hashtable] |
63 | | - $Connection |
| 43 | + [hashtable]$Connection |
64 | 44 | ) |
65 | 45 |
|
66 | 46 | # Query Splat |
|
0 commit comments