Skip to content

Commit c5578e7

Browse files
authored
Merge pull request #90 from joseluislucio/Update-ServiceNowRequestItem
Added Update-ServiceNowRequestItem function
2 parents 41b365c + 2612a80 commit c5578e7

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
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+

ServiceNow/ServiceNow.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ FormatsToProcess = @('ServiceNow.format.ps1xml')
6666
NestedModules = @()
6767

6868
# Functions to export from this module
69-
FunctionsToExport = @('Add-ServiceNowAttachment','Get-ServiceNowAttachment','Get-ServiceNowAttachmentDetail','Get-ServiceNowChangeRequest','Get-ServiceNowConfigurationItem','Get-ServiceNowIncident','Get-ServiceNowRequest','Get-ServiceNowRequestItem','Get-ServiceNowTable','Get-ServiceNowTableEntry','Get-ServiceNowUser','Get-ServiceNowUserGroup','New-ServiceNowChangeRequest','New-ServiceNowIncident','New-ServiceNowQuery','New-ServiceNowTableEntry','Remove-ServiceNowAttachment','Remove-ServiceNowAuth','Remove-ServiceNowTableEntry','Set-ServiceNowAuth','Test-ServiceNowAuthIsSet','Update-ServiceNowChangeRequest','Update-ServiceNowIncident','Update-ServiceNowNumber','Update-ServiceNowTableEntry')
69+
FunctionsToExport = @('Add-ServiceNowAttachment','Get-ServiceNowAttachment','Get-ServiceNowAttachmentDetail','Get-ServiceNowChangeRequest','Get-ServiceNowConfigurationItem','Get-ServiceNowIncident','Get-ServiceNowRequest','Get-ServiceNowRequestItem','Get-ServiceNowTable','Get-ServiceNowTableEntry','Get-ServiceNowUser','Get-ServiceNowUserGroup','New-ServiceNowChangeRequest','New-ServiceNowIncident','New-ServiceNowQuery','New-ServiceNowTableEntry','Remove-ServiceNowAttachment','Remove-ServiceNowAuth','Remove-ServiceNowTableEntry','Set-ServiceNowAuth','Test-ServiceNowAuthIsSet','Update-ServiceNowChangeRequest','Update-ServiceNowIncident','Update-ServiceNowNumber','Update-ServiceNowRequestItem','Update-ServiceNowTableEntry')
7070

7171
# List of all modules packaged with this module
7272
# ModuleList = @()

0 commit comments

Comments
 (0)