Scripts/Remove-BPAWindowConditionControl.ps1
function Remove-BPAWindowConditionControl { <# .SYNOPSIS Removes a control from an AutoMate BPA window condition. .DESCRIPTION Remove-BPAWindowConditionControl removes a control from an AutoMate BPA window condition. .PARAMETER InputObject The window condition object to remove the control from. .PARAMETER ID The ID of the window control. .EXAMPLE Get-BPACondition "window" | Remove-BPAWindowConditionControl -ID "{5ccaab49-012a-48db-b186-696061e20a2c}" .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 02/22/2018 Date Modified : 02/22/2018 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding(DefaultParameterSetName = "Default")] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] $InputObject, [Parameter(Mandatory = $true)] $ID ) PROCESS { foreach ($obj in $InputObject) { if (($obj.TypeName -eq "Condition") -and ($obj.TriggerType -eq [BPATriggerType]::Window.value__)) { $updateObject = Get-BPACondition -ID $obj.ID -BPAServer $obj.BPAServer if ((($updateObject.WindowControl | Where-Object {$_.ID -ne $ID}) | Measure-Object).Count -gt 0) { $updateObject.WindowControl = @($updateObject.WindowControl | Where-Object {$_.ID -ne $ID}) } else { $updateObject.WindowControl = @() } if ($updateObject.WindowControl.Count -eq 0) { $updateObject.ContainsControls = $false } $updateObject | Set-BPAObject } else { Write-Error -Message "Unsupported input type '$($obj.TypeName)' and trigger type '$($obj.TriggerType -as [BPATriggerType])' encountered!" -TargetObject $obj } } } } |