Public/Update-ServiceNowChangeRequest.ps1
<#
.EXAMPLE Update-ServiceNowChangeRequest -Values @{ 'state' = 3 } -SysId <sysid> #> function Update-ServiceNowChangeRequest { [CmdletBinding(DefaultParameterSetName = 'Session', SupportsShouldProcess)] Param( # sys_id of the caller of the incident (use Get-ServiceNowUser to retrieve this) [parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('sys_id')] [string] $SysId, # Hashtable of values to use as the record's properties [parameter(Mandatory)] [hashtable]$Values, # Credential used to authenticate to ServiceNow [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory)] [ValidateNotNullOrEmpty()] [PSCredential]$ServiceNowCredential, # The URL for the ServiceNow instance being used (eg: instancename.service-now.com) [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory)] [ValidateNotNullOrEmpty()] [string]$ServiceNowURL, # Azure Automation Connection object containing username, password, and URL for the ServiceNow instance [Parameter(ParameterSetName = 'UseConnectionObject', Mandatory)] [ValidateNotNullOrEmpty()] [Hashtable]$Connection, [Parameter(ParameterSetName = 'Session')] [ValidateNotNullOrEmpty()] [hashtable] $ServiceNowSession = $script:ServiceNowSession, [Parameter()] [switch] $PassThru ) begin {} process { $params = @{ Method = 'Patch' Table = 'change_request' SysId = $SysId Values = $Values Connection = $Connection Credential = $Credential ServiceNowUrl = $ServiceNowURL ServiceNowSession = $ServiceNowSession } If ($PSCmdlet.ShouldProcess("Change request $SysID", 'Update values')) { $response = Invoke-ServiceNowRestMethod @params if ( $PassThru.IsPresent ) { $response } } } end {} } |