Scripts/Set-BPAUserGroup.ps1
function Set-BPAUserGroup { <# .SYNOPSIS Sets properties of an AutoMate BPA user group. .DESCRIPTION Set-BPAUserGroup can change properties of a user group object. .PARAMETER InputObject The user 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: UserGroup .EXAMPLE # Changes notes for a single user group Get-BPAUserGroup "Users" | Set-BPAUserGroup -Notes "Group containing all users" .EXAMPLE # Empty notes for all user groups Get-BPAUserGroup | 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 "UserGroup") { $updateObject = Get-BPAUserGroup -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 } } } } |