|
1 | | -function Get-ServiceNowConfigurationItem { |
2 | | - param( |
3 | | - # 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', |
9 | | - |
10 | | - # 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', |
17 | | - |
18 | | - # 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, |
24 | | - |
25 | | - # 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=@{}, |
31 | | - |
32 | | - # 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=@{}, |
38 | | - |
39 | | - # 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")] |
45 | | - [string]$DisplayValues='true', |
46 | | - |
47 | | - [Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)] |
48 | | - [ValidateNotNullOrEmpty()] |
49 | | - [PSCredential] |
50 | | - $ServiceNowCredential, |
51 | | - |
52 | | - [Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)] |
53 | | - [ValidateNotNullOrEmpty()] |
54 | | - [string] |
55 | | - $ServiceNowURL, |
56 | | - |
57 | | - [Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)] |
58 | | - [ValidateNotNullOrEmpty()] |
59 | | - [Hashtable] |
60 | | - $Connection |
61 | | - ) |
62 | | - |
63 | | - $Query = New-ServiceNowQuery -OrderBy $OrderBy -OrderDirection $OrderDirection -MatchExact $MatchExact -MatchContains $MatchContains |
64 | | - |
65 | | - if ($Connection -ne $null) { |
66 | | - $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues -Connection $Connection |
67 | | - } |
68 | | - elseif ($ServiceNowCredential -ne $null -and $ServiceNowURL -ne $null) { |
69 | | - $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues -ServiceNowCredential $ServiceNowCredential -ServiceNowURL $ServiceNowURL |
70 | | - } |
71 | | - else { |
72 | | - $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues |
73 | | - } |
74 | | - |
75 | | - |
76 | | - # Set the default property set for the table view |
77 | | - $DefaultProperties = @('name', 'category', 'subcategory') |
78 | | - $DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet(‘DefaultDisplayPropertySet’,[string[]]$DefaultProperties) |
79 | | - $PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]@($DefaultDisplayPropertySet) |
80 | | - $Result | Add-Member MemberSet PSStandardMembers $PSStandardMembers |
81 | | - return $result |
82 | | -} |
| 1 | +function Get-ServiceNowConfigurationItem { |
| 2 | + param( |
| 3 | + # 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', |
| 9 | + |
| 10 | + # 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', |
| 17 | + |
| 18 | + # 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, |
| 24 | + |
| 25 | + # 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=@{}, |
| 31 | + |
| 32 | + # 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=@{}, |
| 38 | + |
| 39 | + # 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")] |
| 45 | + [string]$DisplayValues='true', |
| 46 | + |
| 47 | + [Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)] |
| 48 | + [ValidateNotNullOrEmpty()] |
| 49 | + [PSCredential] |
| 50 | + $ServiceNowCredential, |
| 51 | + |
| 52 | + [Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)] |
| 53 | + [ValidateNotNullOrEmpty()] |
| 54 | + [string] |
| 55 | + $ServiceNowURL, |
| 56 | + |
| 57 | + [Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)] |
| 58 | + [ValidateNotNullOrEmpty()] |
| 59 | + [Hashtable] |
| 60 | + $Connection |
| 61 | + ) |
| 62 | + |
| 63 | + $Query = New-ServiceNowQuery -OrderBy $OrderBy -OrderDirection $OrderDirection -MatchExact $MatchExact -MatchContains $MatchContains |
| 64 | + |
| 65 | + if ($Connection -ne $null) { |
| 66 | + $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues -Connection $Connection |
| 67 | + } |
| 68 | + elseif ($ServiceNowCredential -ne $null -and $ServiceNowURL -ne $null) { |
| 69 | + $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues -ServiceNowCredential $ServiceNowCredential -ServiceNowURL $ServiceNowURL |
| 70 | + } |
| 71 | + else { |
| 72 | + $result = Get-ServiceNowTable -Table 'cmdb_ci' -Query $Query -Limit $Limit -DisplayValues $DisplayValues |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + # Set the default property set for the table view |
| 77 | + $DefaultProperties = @('name', 'category', 'subcategory') |
| 78 | + $DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet('DefaultDisplayPropertySet',[string[]]$DefaultProperties) |
| 79 | + $PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]@($DefaultDisplayPropertySet) |
| 80 | + $Result | Add-Member MemberSet PSStandardMembers $PSStandardMembers |
| 81 | + return $result |
| 82 | +} |
0 commit comments