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