Skip to content

Commit 1b3ca3d

Browse files
committed
v1.0.1 - For PR #22 and Issue #25
1 parent 33b72ea commit 1b3ca3d

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The gains are marginal in some aspects, but intended to allow for better managem
2323

2424
Front End:
2525

26-
* The following fields are now returned in the DateTime format instead of string: 'closed_at','expected_start','follow_up','opened_at','sys_created_on','sys_updated_on','work_end','work_start'
26+
* The following fields are now returned in the DateTime format instead of string: 'closed_at','expected_start','follow_up','opened_at','sys_created_on','sys_updated_on','work_end','work_start' [v1.0.1 Update: This process now attempts to format the property as DateTime based off your local culture settings, a universal `yyyy-MM-dd HH:mm:ss` format, and finally leaves the property as a string if those two convert attempts fail].
2727
* The formatting of returned data has been updated across all the `Get` functions except `Get-ServiceNowTable`. This means you'll see a handful of default properties returned and can use `Format-List` or `Select-Object` to view all other properties associated with the object.
2828

2929
These changes should improve your ability to filter on the right, especially by DateTime, as well as return more information in general.

ServiceNow/Public/Get-ServiceNowTable.ps1

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
function Get-ServiceNowTable {
22
[OutputType([Array])]
3-
Param
4-
(
3+
Param (
54
# Name of the table we're querying (e.g. incidents)
65
[parameter(Mandatory)]
76
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
87
[parameter(ParameterSetName = 'UseConnectionObject')]
98
[parameter(ParameterSetName = 'SetGlobalAuth')]
109
[ValidateNotNullOrEmpty()]
1110
[string]$Table,
12-
11+
1312
# sysparm_query param in the format of a ServiceNow encoded query string (see http://wiki.servicenow.com/index.php?title=Encoded_Query_Strings)
1413
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
1514
[parameter(ParameterSetName = 'UseConnectionObject')]
@@ -28,21 +27,21 @@ function Get-ServiceNowTable {
2827
[parameter(ParameterSetName = 'SetGlobalAuth')]
2928
[ValidateSet("true", "false", "all")]
3029
[string]$DisplayValues = 'false',
31-
32-
# Credential used to authenticate to ServiceNow
30+
31+
# Credential used to authenticate to ServiceNow
3332
[Parameter(ParameterSetName = 'SpecifyConnectionFields')]
3433
[ValidateNotNullOrEmpty()]
3534
[PSCredential]
36-
$ServiceNowCredential,
35+
$ServiceNowCredential,
3736

3837
# The URL for the ServiceNow instance being used
3938
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
4039
[ValidateNotNullOrEmpty()]
4140
[string]
42-
$ServiceNowURL,
41+
$ServiceNowURL,
4342

4443
# Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
45-
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
44+
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
4645
[ValidateNotNullOrEmpty()]
4746
[Hashtable]
4847
$Connection
@@ -53,14 +52,14 @@ function Get-ServiceNowTable {
5352
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
5453
$ServiceNowCredential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
5554
$ServiceNowURL = 'https://' + $Connection.ServiceNowUri + '/api/now/v1'
56-
}
55+
}
5756
elseif ($null -ne $ServiceNowCredential -and $null -ne $ServiceNowURL) {
5857
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
5958
}
6059
elseif ((Test-ServiceNowAuthIsSet)) {
6160
$ServiceNowCredential = $Global:ServiceNowCredentials
6261
$ServiceNowURL = $global:ServiceNowRESTURL
63-
}
62+
}
6463
else {
6564
throw "Exception: You must do one of the following to authenticate: `n 1. Call the Set-ServiceNowAuth cmdlet `n 2. Pass in an Azure Automation connection object `n 3. Pass in an endpoint and credential"
6665
}
@@ -70,7 +69,7 @@ function Get-ServiceNowTable {
7069
if ($Query) {
7170
$Body.sysparm_query = $Query
7271
}
73-
72+
7473
# Perform table query and capture results
7574
$Uri = $ServiceNowURL + "/table/$Table"
7675
$Result = (Invoke-RestMethod -Uri $Uri -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").Result

ServiceNow/ServiceNow.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#
1+
#
22
# Module manifest for module 'ServiceNow'
33
#
44
# Generated by: Sam Martin
@@ -12,7 +12,7 @@
1212
RootModule = 'ServiceNow.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.0'
15+
ModuleVersion = '1.0.1'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'

0 commit comments

Comments
 (0)