@@ -60,25 +60,25 @@ Function Update-ServiceNowNumber {
6060 begin {}
6161 process {
6262 Try {
63- # Use the number and table to determine the sys_id
63+ # Prep a splat to use the provided number to find the sys_id
6464 $getServiceNowTableEntry = @ {
6565 Table = $Table
6666 MatchExact = @ {number = $number }
67- Credential = $Credential
68- ServiceNowURL = $ServiceNowURL
6967 ErrorAction = ' Stop'
7068 }
71- $SysID = Get-ServiceNowTableEntry @getServiceNowTableEntry | Select-Object - Expand sys_id
7269
7370 # Process credential steps based on parameter set name
7471 Switch ($PSCmdlet.ParameterSetName ) {
7572 ' SpecifyConnectionFields' {
7673 $ServiceNowURL = ' https://' + $ServiceNowURL + ' /api/now/v1'
74+ $updateServiceNowTableEntrySplat.Add (' ServiceNowCredential' , $ServiceNowCredential )
75+ $updateServiceNowTableEntrySplat.Add (' ServiceNowURL' , $ServiceNowURL )
7776 }
7877 ' UseConnectionObject' {
7978 $SecurePassword = ConvertTo-SecureString $Connection.Password - AsPlainText - Force
8079 $Credential = New-Object System.Management.Automation.PSCredential ($Connection.Username , $SecurePassword )
8180 $ServiceNowURL = ' https://' + $Connection.ServiceNowUri + ' /api/now/v1'
81+ $updateServiceNowTableEntrySplat.Add (' Connection' , $Connection )
8282 }
8383 Default {
8484 If ((Test-ServiceNowAuthIsSet )) {
@@ -91,6 +91,9 @@ Function Update-ServiceNowNumber {
9191 }
9292 }
9393
94+ # Use the number and table to determine the sys_id
95+ $SysID = Get-ServiceNowTableEntry @getServiceNowTableEntry | Select-Object - Expand sys_id
96+
9497 # Convert the values to Json and encode them to an UTF8 array to support special chars
9598 $Body = $Values | ConvertTo-Json
9699 $utf8Bytes = [System.Text.Encoding ]::Utf8.GetBytes($Body )
0 commit comments