Skip to content

Commit 5e504f9

Browse files
author
Jakob Gottlieb Svendsen
committed
Fixed "New-ServiceNowTableEntry" to support UTF8 chars + Added "CustomFields" param to New-ServiceNowIncident
Fixed "New-ServiceNowTableEntry" to support UTF8 chars such as danish "æ","ø","å" Added "CustomFields" param to New-ServiceNowIncident to be able to support any fields in incident
1 parent 8fc2aac commit 5e504f9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

PSServiceNow-Incidents.psm1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ function New-ServiceNowIncident{
167167
[parameter(ParameterSetName='SetGlobalAuth')]
168168
[string]$ConfigurationItem,
169169

170+
# custom fields as hashtable
171+
[parameter(mandatory=$false)]
172+
[parameter(ParameterSetName='SpecifyConnectionFields')]
173+
[parameter(ParameterSetName='UseConnectionObject')]
174+
[parameter(ParameterSetName='SetGlobalAuth')]
175+
[hashtable]$CustomFields,
176+
170177
# Credential used to authenticate to ServiceNow
171178
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
172179
[ValidateNotNullOrEmpty()]
@@ -198,6 +205,10 @@ function New-ServiceNowIncident{
198205
'cmdb_ci' = $ConfigurationItem
199206
}
200207

208+
if($CustomFields)
209+
{
210+
$Values += $CustomFields
211+
}
201212

202213
if ($Connection -ne $null)
203214
{

PSServiceNow-Tables.psm1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,12 @@ function New-ServiceNowTableEntry{
145145

146146
$Body = $Values | ConvertTo-Json;
147147

148+
#Convert to UTF8 array to support special chars such as the danish "æ","ø","å"
149+
$utf8Bytes = [System.Text.Encoding]::UTf8.GetBytes($Body)
150+
148151
# Fire and return
149152
$Uri = $ServiceNowURL + "/table/$Table"
150-
return (Invoke-RestMethod -Uri $uri -Method Post -Credential $ServiceNowCredential -Body $Body -ContentType "application/json" -UseBasicParsing).result
153+
return (Invoke-RestMethod -Uri $uri -Method Post -Credential $ServiceNowCredential -Body $utf8Bytes -ContentType "application/json" -UseBasicParsing).result
151154
}
152155

153156
<#

PSServiceNow.psd1

Lines changed: 1 addition & 1 deletion
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.3'
15+
ModuleVersion = '0.1.4'
1616

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

0 commit comments

Comments
 (0)