Scripts/Set-BPAAgentGroup.ps1
function Set-BPAAgentGroup { <# .SYNOPSIS Sets properties of an AutoMate BPA agent group. .DESCRIPTION Set-BPAAgentGroup can change properties of an agent group object. .PARAMETER InputObject The agent group to modify. .PARAMETER Notes The new notes to set on the object. .INPUTS The following BPA object types can be modified by this function: AgentGroup .EXAMPLE # Change notes for an agent group Get-BPAAgentGroup "All Agents" | Set-BPAUserGroup -Notes "Group containing all agents" .EXAMPLE # Empty notes for all agent groups Get-BPAAgentGroup | Set-BPAUserGroup -Notes "" .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 11/07/2016 Date Modified : 03/27/2018 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] $InputObject, [Parameter(Mandatory = $true)] [AllowEmptyString()] [string]$Notes ) PROCESS { foreach ($obj in $InputObject) { if ($obj.TypeName -eq "AgentGroup") { $updateObject = Get-BPAAgentGroup -ID $obj.ID -BPAServer $obj.BPAServer $shouldUpdate = $false if ($PSBoundParameters.ContainsKey("Notes")) { if ($updateObject.Notes -ne $Notes) { $updateObject.Notes = $Notes $shouldUpdate = $true } } if ($shouldUpdate) { $updateObject | Set-BPAObject } else { Write-Verbose "$($obj.TypeName) '$($obj.Name)' already contains the specified values." } } else { Write-Error -Message "Unsupported input type '$($obj.TypeName)' encountered!" -TargetObject $obj } } } } |