Set-PendingApprovalRequest

Description

The Set-PendingApprovalRequest cmdlet allows you approve or reject an approval request. The cmdlet can be combined with the Get-ApprovalRequest to approve or reject pending approval requests for the current user.

Syntax

Set-PendingApprovalRequest -ApprovalObject <PSObject> -Decision <ApprovalDecision> [-Reason <string>]

Parameters

ApprovalObject

Required. An Approval object obtained using the Get-ApprovalRequest cmdlet that is in the Pending state

Decision

Required. The approval decision. This can be either Approved or Rejected

Reason

Optional. The reason for the approval or rejection

Examples

Individually get and approve each request

$requests = Get-ApprovalRequest
foreach ($request in $requests)
{
   if ($request.Status -eq "Pending")
   {
       Set-PendingApprovalRequest -ApprovalObject $request -Decision Approved
   }
}

Approve all pending requests using the pipeline

Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Approved -Reason "Make it so!"

Reject all pending requests using the pipeline

Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Reject -Reason "Not today"

Last updated