Skip to content

Commit e00acb0

Browse files
committed
Lost Update-ServiceNowChangeRequest in merge. Adding it back.
1 parent 22eedc4 commit e00acb0

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<#
2+
.EXAMPLE
3+
Update-ServiceNowChangeRequest -Values @{ 'state' = 3 } -SysId <sysid>
4+
#>
5+
function Update-ServiceNowChangeRequest
6+
{
7+
Param(
8+
# sys_id of the caller of the incident (user Get-ServiceNowUser to retrieve this)
9+
[parameter(Mandatory=$true)]
10+
[parameter(ParameterSetName='SpecifyConnectionFields')]
11+
[parameter(ParameterSetName='UseConnectionObject')]
12+
[parameter(ParameterSetName='SetGlobalAuth')]
13+
[string]$SysId,
14+
15+
# Hashtable of values to use as the record's properties
16+
[parameter(Mandatory=$true)]
17+
[hashtable]$Values,
18+
19+
# Credential used to authenticate to ServiceNow
20+
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$true)]
21+
[ValidateNotNullOrEmpty()]
22+
[PSCredential]$ServiceNowCredential,
23+
24+
# The URL for the ServiceNow instance being used (eg: instancename.service-now.com)
25+
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$true)]
26+
[ValidateNotNullOrEmpty()]
27+
[string]$ServiceNowURL,
28+
29+
# Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
30+
[Parameter(ParameterSetName='UseConnectionObject', Mandatory=$true)]
31+
[ValidateNotNullOrEmpty()]
32+
[Hashtable]$Connection
33+
)
34+
35+
$updateServiceNowTableEntrySplat = @{
36+
SysId = $SysId
37+
Table = 'change_request'
38+
Values = $Values
39+
}
40+
41+
# Update the splat if the parameters have values
42+
if ($null -ne $PSBoundParameters.Connection)
43+
{
44+
$updateServiceNowTableEntrySplat.Add('Connection',$Connection)
45+
}
46+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL)
47+
{
48+
$updateServiceNowTableEntrySplat.Add('ServiceNowCredential',$ServiceNowCredential)
49+
$updateServiceNowTableEntrySplat.Add('ServiceNowURL',$ServiceNowURL)
50+
}
51+
52+
Update-ServiceNowTableEntry @updateServiceNowTableEntrySplat
53+
}

0 commit comments

Comments
 (0)