Skip to content

Commit f2f2c28

Browse files
committed
Create Update-ServiceNowRequestItem.ps1
1 parent 4d9f359 commit f2f2c28

File tree

1 file changed

+49
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)