Scripts/Set-BPASnmpConditionCredential.ps1
function Set-BPASnmpConditionCredential { <# .SYNOPSIS Modifies an AutoMate BPA SNMP condition credential. .DESCRIPTION Set-BPASnmpConditionCredential modifies a credential in an AutoMate BPA SNMP condition. .PARAMETER InputObject The SNMP condition object to add the credential to. .PARAMETER ID The ID of the credential. .PARAMETER User The username used to accept authenticated traps. .PARAMETER AuthenticationPassword The password for the specified user. .PARAMETER EncryptionAlgorithm The type encryption to use. .PARAMETER PrivacyPassword The encryption password. .EXAMPLE Get-BPACondition "window" | Set-BPASnmpConditionCredential -ID "{0cee39da-1f6c-424b-a9bd-eeaf17cbd1f2}" -User david .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 02/23/2018 Date Modified : 02/23/2018 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding(DefaultParameterSetName = "Default")] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] $InputObject, [Parameter(Mandatory = $true)] $ID, $User, #$AuthenticationPassword, [BPAEncryptionAlgorithm]$EncryptionAlgorithm = [BPAEncryptionAlgorithm]::NoEncryption #$PrivacyPassword ) PROCESS { foreach ($obj in $InputObject) { if (($obj.TypeName -eq "Condition") -and ($obj.TriggerType -eq [BPATriggerType]::SNMPTrap.value__)) { $updateObject = Get-BPACondition -ID $obj.ID -BPAServer $obj.BPAServer $shouldUpdate = $false foreach ($credential in $updateObject.Credentials | Where-Object {$_.ID -eq $ID}) { if ($PSBoundParameters.ContainsKey("User") -and ($credential.User -ne $User)) { $credential.User = $User $shouldUpdate = $true } <#if ($PSBoundParameters.ContainsKey("AuthenticationPassword") -and ($credential.AuthenticationPassword -ne $AuthenticationPassword)) { $credential.AuthenticationPassword = $AuthenticationPassword $shouldUpdate = $true }#> if ($PSBoundParameters.ContainsKey("EncryptionAlgorithm") -and ($credential.EncryptionAlgorithm -ne $EncryptionAlgorithm.value__)) { $credential.EncryptionAlgorithm = $EncryptionAlgorithm.value__ $shouldUpdate = $true } <#if ($PSBoundParameters.ContainsKey("PrivacyPassword") -and ($credential.PrivacyPassword -ne $PrivacyPassword)) { $credential.PrivacyPassword = $PrivacyPassword $shouldUpdate = $true }#> } if ($shouldUpdate) { $updateObject | Set-BPAObject } } else { Write-Error -Message "Unsupported input type '$($obj.TypeName)' and trigger type '$($obj.TriggerType -as [BPATriggerType])' encountered!" -TargetObject $obj } } } } |