Skip to content

Commit e4fbd18

Browse files
committed
Renamed module from PoshServiceNow to ServiceNow. Build v 0.1.36
1 parent e4bed33 commit e4fbd18

20 files changed

+916
-900
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ServiceNow-Module.Pester.Defaults.json
22
*.zip
3-
PoshServiceNow.Pester.Defaults.json
3+
ServiceNow.Pester.Defaults.json

Readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# PoshServiceNow
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-74%25-orange.svg)
1+
# ServiceNow
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-73%25-orange.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

@@ -8,19 +8,19 @@ Requires PowerShell 3.0 or above as this is when `Invoke-RestMethod` was introdu
88

99
## Usage
1010
Download the [latest release](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) and extract the .psm1 and .psd1 files to your PowerShell profile directory (i.e. the `Modules` directory under wherever `$profile` points to in your PS console) and run:
11-
`Import-Module PoshServiceNow`
12-
Once you've done this, all the cmdlets will be at your disposal, you can see a full list using `Get-Command -Module PoshServiceNow`.
11+
`Import-Module ServiceNow`
12+
Once you've done this, all the cmdlets will be at your disposal, you can see a full list using `Get-Command -Module ServiceNow`.
1313

1414
### Example - Retrieving an Incident Containing the Word 'PowerShell'
1515
```
16-
Import-Module PoshServiceNow
16+
Import-Module ServiceNow
1717
Set-ServiceNowAuth
1818
Get-ServiceNowIncident -MatchContains @{short_description='PowerShell'}
1919
```
2020

2121
### Example - Retrieving an Incident Containing the Word 'PowerShell' While Passing Authentication
2222
```
23-
Import-Module PoshServiceNow
23+
Import-Module ServiceNow
2424
Get-ServiceNowIncident -MatchContains @{short_description='PowerShell'} -ServiceNowCredential $PSCredential -ServiceNowURL $ServiceNowURL
2525
```
2626

@@ -31,7 +31,7 @@ Update-ServiceNowIncident -SysID $Incident.Sys_ID -Values @{comments='Updated vi
3131
```
3232

3333
### Azure Connection Object (Automation Integration Module Support)
34-
The module can use the `Connection` parameter in conjunction with the included `PoshServiceNow-Automation.json` file for use as an Azure automation integration module. Details of the process is available at [Authoring Integration Modules for Azure Automation](https://azure.microsoft.com/en-us/blog/authoring-integration-modules-for-azure-automation).
34+
The module can use the `Connection` parameter in conjunction with the included `ServiceNow-Automation.json` file for use as an Azure automation integration module. Details of the process is available at [Authoring Integration Modules for Azure Automation](https://azure.microsoft.com/en-us/blog/authoring-integration-modules-for-azure-automation).
3535

3636
The `Connection` parameter accepts a hashtable object that requires a username, password, and ServiceNowURL.
3737

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
function Get-ServiceNowChangeRequest {
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='opened_at',
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-
$private:Query = New-ServiceNowQuery -OrderBy $private:OrderBy -OrderDirection $private:OrderDirection -MatchExact $private:MatchExact -MatchContains $private:MatchContains
64-
65-
66-
if ($Connection -ne $null) {
67-
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues -Connection $Connection
68-
}
69-
elseif ($ServiceNowCredential -ne $null -and $ServiceNowURL -ne $null) {
70-
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues -ServiceNowCredential $ServiceNowCredential -ServiceNowURL $ServiceNowURL
71-
}
72-
else {
73-
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues
74-
}
75-
76-
# Add the custom type to the change request to enable a view
77-
$private:result | ForEach-Object {$_.psobject.TypeNames.Insert(0, "PoshServiceNow.ChangeRequest")}
78-
return $private:result
79-
}
1+
function Get-ServiceNowChangeRequest {
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='opened_at',
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+
$private:Query = New-ServiceNowQuery -OrderBy $private:OrderBy -OrderDirection $private:OrderDirection -MatchExact $private:MatchExact -MatchContains $private:MatchContains
64+
65+
66+
if ($Connection -ne $null) {
67+
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues -Connection $Connection
68+
}
69+
elseif ($ServiceNowCredential -ne $null -and $ServiceNowURL -ne $null) {
70+
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues -ServiceNowCredential $ServiceNowCredential -ServiceNowURL $ServiceNowURL
71+
}
72+
else {
73+
$private:result = Get-ServiceNowTable -Table 'change_request' -Query $private:Query -Limit $private:Limit -DisplayValues $private:DisplayValues
74+
}
75+
76+
# Add the custom type to the change request to enable a view
77+
$private:result | ForEach-Object {$_.psobject.TypeNames.Insert(0, "ServiceNow.ChangeRequest")}
78+
return $private:result
79+
}

PoshServiceNow/Public/Get-ServiceNowConfigurationItem.ps1 renamed to ServiceNow/Public/Get-ServiceNowConfigurationItem.ps1

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,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-
}
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

Comments
 (0)