Scripts/Unlock-BPAObject.ps1
function Unlock-BPAObject { <# .SYNOPSIS Unlocks an AutoMate BPA object. .DESCRIPTION Unlock-BPAObject receives BPA object(s) on the pipeline, or via the parameter $InputObject, and unlocks the object(s). .PARAMETER InputObject The object(s) to be unlocked. .INPUTS The following objects can be unlocked by this function: Workflow Task Process .EXAMPLE Get-BPAWorkflow "My Workflow" | Unlock-BPAObject .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 11/07/2016 Date Modified : 02/08/2018 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding()] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] $InputObject ) PROCESS { foreach ($obj in $InputObject) { switch ($obj.TypeName) { "Workflow" { $update = Get-BPAWorkflow -ID $obj.ID -BPAServer $obj.BPAServer } "Task" { $update = Get-BPATask -ID $obj.ID -BPAServer $obj.BPAServer } "Condition" { $update = Get-BPACondition -ID $obj.ID -BPAServer $obj.BPAServer } "Process" { $update = Get-BPAProcess -ID $obj.ID -BPAServer $obj.BPAServer } default { Write-Error -Message "Unsupported input type '$($obj.TypeName)' encountered!" -TargetObject $obj } } $update.LockedBy = "" $update | Set-BPAObject Write-Verbose "Unlocked $($obj.TypeName) '$($obj.Name)'." } } } |