functions/customSecurityAttributes/customSecurityAttributeAllowedValues/Register-TmfCustomSecurityAttributeAllowedValue.ps1
function Register-TmfCustomSecurityAttributeAllowedValue { [CmdletBinding()] Param ( [Parameter(Mandatory = $true)] [string] $displayName, [Parameter(Mandatory = $true)] [bool] $isActive, [Parameter(Mandatory = $true)] [string] $attributeId, [bool] $present = $true, [string] $sourceConfig = "<Custom>", [System.Management.Automation.PSCmdlet] $Cmdlet = $PSCmdlet ) begin { $resourceName = "customSecurityAttributeAllowedValues" if (!$script:desiredConfiguration[$resourceName]) { $script:desiredConfiguration[$resourceName] = @() } $id = $displayName $displayName = "$($attributeId)_$($id)" if ($script:desiredConfiguration[$resourceName].displayName -contains $displayName) { $alreadyLoaded = $script:desiredConfiguration[$resourceName] | Where-Object {$_.displayName -eq $displayName} } } process { if (Test-PSFFunctionInterrupt) { return } $object = [PSCustomObject]@{ displayName = $displayName id = $id isActive = $isActive attributeId = $attributeId present = $present sourceConfig = $sourceConfig } Add-Member -InputObject $object -MemberType ScriptMethod -Name Properties -Value { ($this | Get-Member -MemberType NoteProperty).Name } if ($alreadyLoaded) { $script:desiredConfiguration[$resourceName][$script:desiredConfiguration[$resourceName].IndexOf($alreadyLoaded)] = $object } else { $script:desiredConfiguration[$resourceName] += $object } } } |