Public/Get-PWSHPUKMGT-User.ps1
|
<# .SYNOPSIS Gets the user linked to a crypto device serial number. .DESCRIPTION Looks up the PWSHPUKMGT record for the given crypto device serial number in the configured hosting backend (flat file or Active Directory) and returns the linked user's identity. In both hosting models the serial number is stored inside an encrypted blob, so this search is performed by decrypting and comparing candidate records; it is not an indexed lookup. .PARAMETER SerialNumber The crypto device serial number to search for. Accepts pipeline input. .PARAMETER Server The domain controller to run the underlying LDAP requests against. Defaults to the value configured in hosting.activeDirectory.server, or, if that is not set either, to the primary domain controller (PDC emulator) of the current domain. .EXAMPLE Get-PWSHPUKMGT-User -SerialNumber 'YK-00123456' .OUTPUTS PSCustomObject Has SerialNumber and DistinguishedName properties. #> function Get-PWSHPUKMGT-User { [CmdletBinding()] [OutputType([psobject])] param( [Parameter(Mandatory, Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string]$SerialNumber, [string]$Server ) begin { $config = Get-PukModuleConfig $certificate = Test-PukCertificate -Thumbprint $config.certificate.thumbprint -StoreLocation $config.certificate.storeLocation -RequiredEkuOids $config.certificate.requiredEkuOids $effectiveServer = Resolve-PukServer -Server $Server -Config $config } process { $record = Get-PukRecord -Config $config -Certificate $certificate -SerialNumber $SerialNumber -Server $effectiveServer if (-not $record) { Write-Error "No PWSHPUKMGT record found for device serial number '$SerialNumber'." return } [PSCustomObject]@{ PSTypeName = 'PWSHPUKMGT.UserResult' SerialNumber = $SerialNumber DistinguishedName = $record.DistinguishedName } } } |