Scripts/Set-BPAUser.ps1
function Set-BPAUser { <# .SYNOPSIS Sets properties of an AutoMate BPA user. .DESCRIPTION Set-BPAUser can change properties of a user object. .PARAMETER InputObject The object to modify. .PARAMETER Notes The new notes to set on the object. .EXAMPLE # Change notes for a user Get-BPAUser -Name David | Set-BPAUser -Notes "Email address: david@example.com" .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 "User") { $updateObject = Get-BPAUser -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 } } } } |