Scripts/Add-BPAWindowConditionControl.ps1
function Add-BPAWindowConditionControl { <# .SYNOPSIS Adds a control to an AutoMate BPA window condition. .DESCRIPTION Add-BPAWindowConditionControl adds a control to an AutoMate BPA window condition. .PARAMETER InputObject The window condition object to add the control to. .PARAMETER Class The class of the control. .PARAMETER Name The name of the control. .PARAMETER Type The type of control. .PARAMETER Value The value of the control. .PARAMETER XPosition The X position of the control on screen. .PARAMETER YPosition The Y position of the control on screen. .EXAMPLE Get-BPACondition "window" | Add-BPAWindowConditionControl -Class ConsoleWindowClass -Name Close -Type PushButton .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, $Class, $Name, $Type, $Value, $XPosition, $YPosition ) 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 $windowcontrol = Get-BPAObjectTemplate -Type WindowsControl -BPAServer $obj.BPAServer $windowcontrol.ID = "{$((New-Guid).Guid)}" if ($PSBoundParameters.ContainsKey("Class")) { $windowcontrol.Class = $Class $windowcontrol.CheckClass = $true } if ($PSBoundParameters.ContainsKey("Name")) { $windowcontrol.Name = $Name $windowcontrol.CheckName = $true } if ($PSBoundParameters.ContainsKey("Type")) { $windowcontrol.Type = $Type $windowcontrol.CheckType = $true } if ($PSBoundParameters.ContainsKey("Value")) { $windowcontrol.Value = $Value $windowcontrol.CheckValue = $true } if ($PSBoundParameters.ContainsKey("XPosition")) { $windowcontrol.Xpos = $XPosition $windowcontrol.CheckPosition = $true } if ($PSBoundParameters.ContainsKey("YPosition")) { $windowcontrol.Ypos = $YPosition $windowcontrol.CheckPosition = $true } $updateObject.WindowControl += $windowcontrol $updateObject.ContainsControls = $true $updateObject | Set-BPAObject } else { Write-Error -Message "Unsupported input type '$($obj.TypeName)' and trigger type '$($obj.TriggerType -as [BPATriggerType])' encountered!" -TargetObject $obj } } } } |