Private/Storage/Set-PukRecord.ps1
|
function Set-PukRecord { [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [psobject]$Config, [Parameter(Mandatory)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate, [Parameter(Mandatory)] [psobject]$Record, [string]$Server, [switch]$Force ) if (-not $PSCmdlet.ShouldProcess($Record.DistinguishedName, 'Set PWSHPUKMGT record')) { return } switch ($Config.hosting.model) { 'FlatFile' { Set-PukFlatFileRecord -Path $Config.hosting.flatFile.path -Certificate $Certificate -Record $Record -Force:$Force -Confirm:$false } 'ActiveDirectory' { $params = @{ AttributeName = $Config.hosting.activeDirectory.attributeName; Certificate = $Certificate; Record = $Record; Force = $Force; Confirm = $false } $effectiveServer = if ($Server) { $Server } else { $Config.hosting.activeDirectory.server } if ($effectiveServer) { $params.Server = $effectiveServer } if ($Config.hosting.activeDirectory.maxAttributeValueLength) { $params.MaxAttributeValueLength = $Config.hosting.activeDirectory.maxAttributeValueLength } Set-PukAdRecord @params } default { throw "Unsupported hosting model '$($Config.hosting.model)'." } } } |