functions/customSecurityAttributes/attributeSets/Register-TmfAttributeSet.ps1
function Register-TmfAttributeSet { [CmdletBinding()] Param ( [Parameter(Mandatory = $true)] [string] $displayName, [Parameter(Mandatory = $true)] [string] $description, [Parameter(Mandatory = $true)] [int] $maxAttributesPerSet, [bool] $present = $true, [string] $sourceConfig = "<Custom>", [System.Management.Automation.PSCmdlet] $Cmdlet = $PSCmdlet ) begin { $resourceName = "attributeSets" if (!$script:desiredConfiguration[$resourceName]) { $script:desiredConfiguration[$resourceName] = @() } 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 description = $description maxAttributesPerSet = $maxAttributesPerSet 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 } } } |