Skip to content

Commit

Permalink
v1.0.1 - For PR #22 and Issue #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick-2CA committed Jan 16, 2018
1 parent 33b72ea commit 1b3ca3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The gains are marginal in some aspects, but intended to allow for better managem

Front End:

* 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'
* 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].
* 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.

These changes should improve your ability to filter on the right, especially by DateTime, as well as return more information in general.
Expand Down
21 changes: 10 additions & 11 deletions ServiceNow/Public/Get-ServiceNowTable.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
function Get-ServiceNowTable {
[OutputType([Array])]
Param
(
Param (
# Name of the table we're querying (e.g. incidents)
[parameter(Mandatory)]
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
[parameter(ParameterSetName = 'UseConnectionObject')]
[parameter(ParameterSetName = 'SetGlobalAuth')]
[ValidateNotNullOrEmpty()]
[string]$Table,

# sysparm_query param in the format of a ServiceNow encoded query string (see http://wiki.servicenow.com/index.php?title=Encoded_Query_Strings)
[parameter(ParameterSetName = 'SpecifyConnectionFields')]
[parameter(ParameterSetName = 'UseConnectionObject')]
Expand All @@ -28,21 +27,21 @@ function Get-ServiceNowTable {
[parameter(ParameterSetName = 'SetGlobalAuth')]
[ValidateSet("true", "false", "all")]
[string]$DisplayValues = 'false',
# Credential used to authenticate to ServiceNow

# Credential used to authenticate to ServiceNow
[Parameter(ParameterSetName = 'SpecifyConnectionFields')]
[ValidateNotNullOrEmpty()]
[PSCredential]
$ServiceNowCredential,
$ServiceNowCredential,

# The URL for the ServiceNow instance being used
[Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory = $True)]
[ValidateNotNullOrEmpty()]
[string]
$ServiceNowURL,
$ServiceNowURL,

# Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
[Parameter(ParameterSetName = 'UseConnectionObject', Mandatory = $True)]
[ValidateNotNullOrEmpty()]
[Hashtable]
$Connection
Expand All @@ -53,14 +52,14 @@ function Get-ServiceNowTable {
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
$ServiceNowCredential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
$ServiceNowURL = 'https://' + $Connection.ServiceNowUri + '/api/now/v1'
}
}
elseif ($null -ne $ServiceNowCredential -and $null -ne $ServiceNowURL) {
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
}
elseif ((Test-ServiceNowAuthIsSet)) {
$ServiceNowCredential = $Global:ServiceNowCredentials
$ServiceNowURL = $global:ServiceNowRESTURL
}
}
else {
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"
}
Expand All @@ -70,7 +69,7 @@ function Get-ServiceNowTable {
if ($Query) {
$Body.sysparm_query = $Query
}

# Perform table query and capture results
$Uri = $ServiceNowURL + "/table/$Table"
$Result = (Invoke-RestMethod -Uri $Uri -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").Result
Expand Down
4 changes: 2 additions & 2 deletions ServiceNow/ServiceNow.psd1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# Module manifest for module 'ServiceNow'
#
# Generated by: Sam Martin
Expand All @@ -12,7 +12,7 @@
RootModule = 'ServiceNow.psm1'

# Version number of this module.
ModuleVersion = '1.0.0'
ModuleVersion = '1.0.1'

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

0 comments on commit 1b3ca3d

Please sign in to comment.