Skip to content

Commit 056d79c

Browse files
authored
Merge pull request #75 from Sam-Martin/development
v1.5.1 - Specified connection parameters bug fix
2 parents 61686e2 + b841047 commit 056d79c

12 files changed

+39
-27
lines changed

Build/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ForEach ($Module in $Modules) {
2929
}
3030

3131
$Path = (Resolve-Path $PSScriptRoot\..).Path
32-
Set-BuildEnvironment -Path $Path
32+
Set-BuildEnvironment -Path $Path -Force
3333

3434
$invokepsakeSplat = @{
3535
buildFile = "$PSScriptRoot\psake.ps1"

ServiceNow/Public/Get-ServiceNowChangeRequest.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ function Get-ServiceNowChangeRequest {
6767

6868
# Update the Table Splat if the parameters have values
6969
if ($null -ne $PSBoundParameters.Connection) {
70-
$getServiceNowTableSplat.Add('Connection',$Connection)
70+
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
74-
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
74+
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

7777
# Only add the Limit parameter if it was explicitly provided

ServiceNow/Public/Get-ServiceNowConfigurationItem.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ function Get-ServiceNowConfigurationItem {
6767

6868
# Update the Table Splat if the parameters have values
6969
if ($null -ne $PSBoundParameters.Connection) {
70-
$getServiceNowTableSplat.Add('Connection',$Connection)
70+
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
74-
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
74+
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

7777
# Only add the Limit parameter if it was explicitly provided

ServiceNow/Public/Get-ServiceNowIncident.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ function Get-ServiceNowIncident{
6767

6868
# Update the splat if the parameters have values
6969
if ($null -ne $PSBoundParameters.Connection) {
70-
$getServiceNowTableSplat.Add('Connection',$Connection)
70+
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
74-
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
74+
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

7777
# Only add the Limit parameter if it was explicitly provided

ServiceNow/Public/Get-ServiceNowRequest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function Get-ServiceNowRequest {
7070
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
7474
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

ServiceNow/Public/Get-ServiceNowRequestItem.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Get-ServiceNowRequestItem {
8585
$getServiceNowTableSplat.Add('Connection', $Connection)
8686
}
8787
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
88-
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
88+
$getServiceNowTableSplat.Add('Credential', $Credential)
8989
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
9090
}
9191

ServiceNow/Public/Get-ServiceNowTable.ps1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ function Get-ServiceNowTable {
5757
# Get credential and ServiceNow REST URL
5858
if ($null -ne $Connection) {
5959
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
60-
$ServiceNowCredential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
60+
$Credential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
6161
$ServiceNowURL = 'https://' + $Connection.ServiceNowUri + '/api/now/v1'
6262
}
63-
elseif ($null -ne $ServiceNowCredential -and $null -ne $ServiceNowURL) {
64-
Test-ServiceNowURL -Url $ServiceNowURL
65-
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
63+
elseif ($null -ne $Credential -and $null -ne $ServiceNowURL) {
64+
Try {
65+
$null = Test-ServiceNowURL -Url $ServiceNowURL -ErrorAction Stop
66+
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
67+
}
68+
Catch {
69+
Throw $PSItem
70+
}
6671
}
6772
elseif ((Test-ServiceNowAuthIsSet)) {
68-
$ServiceNowCredential = $Global:ServiceNowCredentials
73+
$Credential = $Global:ServiceNowCredentials
6974
$ServiceNowURL = $global:ServiceNowRESTURL
7075
}
7176
else {
@@ -124,7 +129,7 @@ function Get-ServiceNowTable {
124129

125130
# Perform table query and capture results
126131
$Uri = $ServiceNowURL + "/table/$Table"
127-
$Result = (Invoke-RestMethod -Uri $Uri -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").Result
132+
$Result = (Invoke-RestMethod -Uri $Uri -Credential $Credential -Body $Body -ContentType "application/json").Result
128133

129134
# Convert specific fields to DateTime format
130135
$ConvertToDateField = @('closed_at', 'expected_start', 'follow_up', 'opened_at', 'sys_created_on', 'sys_updated_on', 'work_end', 'work_start')

ServiceNow/Public/Get-ServiceNowTableEntry.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function Get-ServiceNowTableEntry {
9494
# Update the Table Splat if an applicable parameter set name is in use
9595
Switch ($PSCmdlet.ParameterSetName) {
9696
'SpecifyConnectionFields' {
97-
$getServiceNowTableSplat.Add('ServiceNowCredential', $Credential)
97+
$getServiceNowTableSplat.Add('Credential', $Credential)
9898
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
9999
}
100100
'UseConnectionObject' {

ServiceNow/Public/Get-ServiceNowUser.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ function Get-ServiceNowUser{
6767

6868
# Update the splat if the parameters have values
6969
if ($null -ne $PSBoundParameters.Connection) {
70-
$getServiceNowTableSplat.Add('Connection',$Connection)
70+
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
7474
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

ServiceNow/Public/Get-ServiceNowUserGroup.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ function Get-ServiceNowUserGroup{
6767

6868
# Update the splat if the parameters have values
6969
if ($null -ne $PSBoundParameters.Connection) {
70-
$getServiceNowTableSplat.Add('Connection',$Connection)
70+
$getServiceNowTableSplat.Add('Connection', $Connection)
7171
}
7272
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
73-
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
73+
$getServiceNowTableSplat.Add('Credential', $Credential)
7474
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7575
}
7676

0 commit comments

Comments
 (0)