diff --git a/Readme.md b/Readme.md index 6daa751..56912ce 100644 --- a/Readme.md +++ b/Readme.md @@ -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. diff --git a/ServiceNow/Public/Get-ServiceNowTable.ps1 b/ServiceNow/Public/Get-ServiceNowTable.ps1 index 0b3c524..d80f929 100644 --- a/ServiceNow/Public/Get-ServiceNowTable.ps1 +++ b/ServiceNow/Public/Get-ServiceNowTable.ps1 @@ -1,7 +1,6 @@ function Get-ServiceNowTable { [OutputType([Array])] - Param - ( + Param ( # Name of the table we're querying (e.g. incidents) [parameter(Mandatory)] [parameter(ParameterSetName = 'SpecifyConnectionFields')] @@ -9,7 +8,7 @@ function Get-ServiceNowTable { [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')] @@ -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 @@ -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" } @@ -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 diff --git a/ServiceNow/ServiceNow.psd1 b/ServiceNow/ServiceNow.psd1 index 93c4a36..d36b962 100644 --- a/ServiceNow/ServiceNow.psd1 +++ b/ServiceNow/ServiceNow.psd1 @@ -1,4 +1,4 @@ -# +# # Module manifest for module 'ServiceNow' # # Generated by: Sam Martin @@ -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'