Skip to content

Commit c54b51c

Browse files
authored
Merge pull request #62 from Sam-Martin/development
v1.3.5 from dev to prod
2 parents 1e2287a + 75ce655 commit c54b51c

File tree

4 files changed

+102
-3
lines changed

4 files changed

+102
-3
lines changed

Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ServiceNow
22

3-
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-79%25-yellow.svg)
3+
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-80%25-yellow.svg)
44

55
This PowerShell module provides a series of cmdlets for interacting with the [ServiceNow REST API](http://wiki.servicenow.com/index.php?title=REST_API), performed by wrapping `Invoke-RestMethod` for the API calls.
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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)]
20+
param(
21+
# Machine name of the field to order by
22+
[parameter(Mandatory = $false)]
23+
[string]$OrderBy = 'opened_at',
24+
25+
# Direction of ordering (Desc/Asc)
26+
[parameter(Mandatory = $false)]
27+
[ValidateSet('Desc', 'Asc')]
28+
[string]$OrderDirection = 'Desc',
29+
30+
# Maximum number of records to return
31+
[parameter(Mandatory = $false)]
32+
[int]$Limit = 10,
33+
34+
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
35+
[parameter(Mandatory = $false)]
36+
[hashtable]$MatchExact = @{},
37+
38+
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
39+
[parameter(Mandatory = $false)]
40+
[hashtable]$MatchContains = @{},
41+
42+
# Whether or not to show human readable display values instead of machine values
43+
[parameter(Mandatory = $false)]
44+
[ValidateSet('true', 'false', 'all')]
45+
[string]$DisplayValues = 'true',
46+
47+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
48+
[ValidateNotNullOrEmpty()]
49+
[Alias('ServiceNowCredential')]
50+
[PSCredential]$Credential,
51+
52+
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
53+
[ValidateNotNullOrEmpty()]
54+
[string]$ServiceNowURL,
55+
56+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
57+
[ValidateNotNullOrEmpty()]
58+
[hashtable]$Connection
59+
)
60+
61+
# Query Splat
62+
$newServiceNowQuerySplat = @{
63+
OrderBy = $OrderBy
64+
MatchExact = $MatchExact
65+
OrderDirection = $OrderDirection
66+
MatchContains = $MatchContains
67+
}
68+
$Query = New-ServiceNowQuery @newServiceNowQuerySplat
69+
70+
# Table Splat
71+
$getServiceNowTableSplat = @{
72+
Table = 'sc_req_item'
73+
Query = $Query
74+
Limit = $Limit
75+
DisplayValues = $DisplayValues
76+
}
77+
78+
# Update the Table Splat if the parameters have values
79+
if ($null -ne $PSBoundParameters.Connection) {
80+
$getServiceNowTableSplat.Add('Connection', $Connection)
81+
}
82+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
83+
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
84+
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
85+
}
86+
87+
# Perform query and return each object in the format.ps1xml format
88+
$Result = Get-ServiceNowTable @getServiceNowTableSplat
89+
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0,'ServiceNow.Request')}
90+
$Result
91+
}

ServiceNow/ServiceNow.psd1

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'ServiceNow.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.2.4'
15+
ModuleVersion = '1.3.5'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'
@@ -66,7 +66,7 @@ FormatsToProcess = @('ServiceNow.format.ps1xml')
6666
NestedModules = @()
6767

6868
# Functions to export from this module
69-
FunctionsToExport = @('Get-ServiceNowChangeRequest','Get-ServiceNowConfigurationItem','Get-ServiceNowIncident','Get-ServiceNowRequest','Get-ServiceNowTable','Get-ServiceNowTableEntry','Get-ServiceNowUser','Get-ServiceNowUserGroup','New-ServiceNowIncident','New-ServiceNowQuery','New-ServiceNowTableEntry','Remove-ServiceNowAuth','Remove-ServiceNowTableEntry','Set-ServiceNowAuth','Test-ServiceNowAuthIsSet','Update-ServiceNowChangeRequest','Update-ServiceNowIncident','Update-ServiceNowNumber','Update-ServiceNowTableEntry')
69+
FunctionsToExport = @('Get-ServiceNowChangeRequest','Get-ServiceNowConfigurationItem','Get-ServiceNowIncident','Get-ServiceNowRequest','Get-ServiceNowRequestItem','Get-ServiceNowTable','Get-ServiceNowTableEntry','Get-ServiceNowUser','Get-ServiceNowUserGroup','New-ServiceNowIncident','New-ServiceNowQuery','New-ServiceNowTableEntry','Remove-ServiceNowAuth','Remove-ServiceNowTableEntry','Set-ServiceNowAuth','Test-ServiceNowAuthIsSet','Update-ServiceNowChangeRequest','Update-ServiceNowIncident','Update-ServiceNowNumber','Update-ServiceNowTableEntry')
7070

7171
# List of all modules packaged with this module
7272
# ModuleList = @()
@@ -107,3 +107,7 @@ PrivateData = @{
107107

108108

109109

110+
111+
112+
113+

Tests/ServiceNow.Tests.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Describe "ServiceNow-Module" {
7979
([array](Get-ServiceNowRequest)).count -gt 0 | Should -Match $true
8080
}
8181

82+
It "Get-ServiceNowRequestItem returns records" {
83+
([array](Get-ServiceNowRequestItem)).count -gt 0 | Should -Match $true
84+
}
85+
8286
It "Get-ServiceNowUserGroup works" {
8387
(Get-ServiceNowUserGroup).Count -gt 0 | Should -Match $true
8488
}

0 commit comments

Comments
 (0)