Skip to content

Commit efee4c4

Browse files
committed
Added Get-ServiceNowChangeRequest
1 parent 6a162a4 commit efee4c4

6 files changed

+119
-6
lines changed

MAKE.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function New-MakePackage{
1313
[string]$PackageName,
1414
[string]$ModuleName
1515
)
16-
($FilePatternExclusions | %{"MAKE.zip" -match $_}).contains($true)
16+
@($FilePatternExclusions | %{"MAKE.zip" -match $_}).contains($true)
1717

1818
$FilesToInclude = Get-ChildItem -Path $here | ?{
1919
$File=$_;
@@ -66,7 +66,7 @@ $PackageFilePatternExclusions = @(
6666

6767
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
6868

69-
$Version = "0.1.1"
69+
$Version = "0.1.2"
7070
$ModuleName = "PSServiceNow"
7171
$PackageName = "$ModuleName-v$($version).zip";
7272

PSServiceNow-Changes.psm1

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function Get-ServiceNowChangeRequest {
2+
param(
3+
# Machine name of the field to order by
4+
[parameter(mandatory=$false)]
5+
[string]$OrderBy='opened_at',
6+
7+
# Direction of ordering (Desc/Asc)
8+
[parameter(mandatory=$false)]
9+
[ValidateSet("Desc", "Asc")]
10+
[string]$OrderDirection='Desc',
11+
12+
# Maximum number of records to return
13+
[parameter(mandatory=$false)]
14+
[int]$Limit=10,
15+
16+
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
17+
[parameter(mandatory=$false)]
18+
[hashtable]$MatchExact=@{},
19+
20+
# Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
21+
[parameter(mandatory=$false)]
22+
[hashtable]$MatchContains=@{},
23+
24+
# Whether or not to show human readable display values instead of machine values
25+
[parameter(mandatory=$false)]
26+
[ValidateSet("true","false", "all")]
27+
[string]$DisplayValues='true'
28+
)
29+
30+
$private:Query = New-ServiceNowQuery -OrderBy $private:OrderBy -OrderDirection $private:OrderDirection -MatchExact $private:MatchExact -MatchContains $private:MatchContains
31+
32+
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues;
33+
34+
# Add the custom type to the change request to enable a view
35+
$private:result | %{$_.psobject.TypeNames.Insert(0, "PSServiceNow.ChangeRequest")}
36+
return $private:result
37+
}

PSServiceNow.Tests.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if(Test-Path $DefaultsFile){
1818
ServiceNowURL = 'testingurl.service-now.com'
1919
TestCategory = 'Internal'
2020
TestUserGroup = 'e9e9a2406f4c35001855fa0dba3ee4f3'
21+
TestUser = "7a4b573a6f3725001855fa0dba3ee485"
2122
} | ConvertTo-Json | Set-Content $DefaultsFile
2223
return;
2324
}
@@ -66,4 +67,8 @@ Describe "ServiceNow-Module" {
6667
# There should be one or more configuration items returned
6768
(Get-ServiceNowConfigurationItem).Count -gt 0 | Should Match $true
6869
}
70+
71+
It "Get-ServiceNowChangeRequest works" {
72+
(Get-ServiceNowChangeRequest).Count -gt 0 | Should Match $true
73+
}
6974
}

PSServiceNow.format.ps1xml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration>
3+
<ViewDefinitions>
4+
<View>
5+
<Name>PSServiceNow.ChangeRequest</Name>
6+
<ViewSelectedBy>
7+
<TypeName>PSServiceNow.ChangeRequest</TypeName>
8+
</ViewSelectedBy>
9+
<TableControl>
10+
<TableHeaders>
11+
<TableColumnHeader>
12+
<Width>20</Width>
13+
</TableColumnHeader>
14+
<TableColumnHeader />
15+
<TableColumnHeader>
16+
<Width>20</Width>
17+
</TableColumnHeader>
18+
<TableColumnHeader>
19+
<Label>assigned_to</Label>
20+
<Width>20</Width>
21+
</TableColumnHeader>
22+
<TableColumnHeader>
23+
<Width>20</Width>
24+
</TableColumnHeader>
25+
<TableColumnHeader>
26+
<Label>cmdb_ci</Label>
27+
<Width>30</Width>
28+
</TableColumnHeader>
29+
<TableColumnHeader>
30+
<Width>20</Width>
31+
</TableColumnHeader>
32+
</TableHeaders>
33+
<TableRowEntries>
34+
<TableRowEntry>
35+
<TableColumnItems>
36+
<TableColumnItem>
37+
<PropertyName>number</PropertyName>
38+
</TableColumnItem>
39+
<TableColumnItem>
40+
<PropertyName>short_description</PropertyName>
41+
</TableColumnItem>
42+
<TableColumnItem>
43+
<PropertyName>state</PropertyName>
44+
</TableColumnItem>
45+
<TableColumnItem>
46+
<ScriptBlock>
47+
$_.assigned_to.display_value
48+
</ScriptBlock>
49+
</TableColumnItem>
50+
<TableColumnItem>
51+
<PropertyName>approval</PropertyName>
52+
</TableColumnItem>
53+
<TableColumnItem>
54+
<ScriptBlock>
55+
$_.cmdb_ci.display_value
56+
</ScriptBlock>
57+
</TableColumnItem>
58+
<TableColumnItem>
59+
<PropertyName>opened_at</PropertyName>
60+
</TableColumnItem>
61+
62+
</TableColumnItems>
63+
</TableRowEntry>
64+
</TableRowEntries>
65+
</TableControl>
66+
</View>
67+
</ViewDefinitions>
68+
</Configuration>

PSServiceNow.psd1

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSServiceNow.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.1.1'
15+
ModuleVersion = '0.1.2'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'
@@ -60,14 +60,15 @@ Copyright = '(c) 2015 Sam. All rights reserved.'
6060
# TypesToProcess = @()
6161

6262
# Format files (.ps1xml) to be loaded when importing this module
63-
# FormatsToProcess = @()
63+
FormatsToProcess = @('PSServiceNow.format.ps1xml')
6464

6565
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6666
NestedModules = @(
6767
'PSServiceNow-Tables.psm1',
6868
'PSServiceNow-Incidents.psm1',
6969
'PSServiceNow-Users.psm1',
70-
'PSServiceNow-ConfigurationManagement.psm1'
70+
'PSServiceNow-ConfigurationManagement.psm1',
71+
'PSServiceNow-Changes.psm1'
7172
)
7273

7374
# Functions to export from this module

Readme.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PSServiceNow
2-
[![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-86%25-yellowgreen.svg)
2+
[![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-87%25-yellowgreen.svg)
33
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.
44
**IMPORTANT:** Neither this module, nor its creator are in any way affiliated with ServiceNow.
55

@@ -19,6 +19,7 @@ Get-ServiceNowIncident -MatchContains @{short_description='PowerShell'}
1919
```
2020

2121
## Cmdlets
22+
* Get-ServiceNowChangeRequest
2223
* Get-ServiceNowConfigurationItem
2324
* Get-ServiceNowIncident
2425
* Get-ServiceNowTable
@@ -28,6 +29,7 @@ Get-ServiceNowIncident -MatchContains @{short_description='PowerShell'}
2829
* New-ServiceNowQuery
2930
* New-ServiceNowTableEntry
3031
* Remove-ServiceNowAuth
32+
* Remove-ServiceNowTableEntry
3133
* Set-ServiceNowAuth
3234
* Test-ServiceNowAuthIsSet
3335

0 commit comments

Comments
 (0)