Skip to content

Get-DbaComputerCertificate - Keep the friendly name of certificates on remote computers - #10668

Open
andreasjordan wants to merge 1 commit into
developmentfrom
fix-getdbacomputercertificate-friendlyname
Open

Get-DbaComputerCertificate - Keep the friendly name of certificates on remote computers#10668
andreasjordan wants to merge 1 commit into
developmentfrom
fix-getdbacomputercertificate-friendlyname

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Problem

For a remote computer, Get-DbaComputerCertificate returns certificates whose FriendlyName is empty, although the certificate in the remote store has one and the command's own Name property carries it. New-DbaComputerCertificate returns this object for remote computers, so its documented FriendlyName was empty there too, while local results had it.

Mechanism

PowerShell remoting rebuilds the X509Certificate2 on the calling side from its raw bytes. The friendly name is a property of the store entry, not of the certificate, so it does not survive the trip - and a remote note property of the same name does not survive either (probed), which is why the scriptblock already exposes it as Name.

What changed

The command copies Name back into FriendlyName on the calling side when it arrives empty. Local and remote results now carry the same properties; nothing changes for localhost. The .OUTPUTS note on Name says so.

Tests

  • New test: pins that both Name and FriendlyName carry the friendly name. It runs locally in CI, where no second computer exists.
  • Lab: Get-DbaComputerCertificate and New-DbaComputerCertificate against a second computer on PowerShell 7.6 and 5.1 - both now return the friendly name for the remote host, unchanged for localhost. Get-DbaComputerCertificate.Tests.ps1 green through the testing-dbatools harness.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…n remote computers

For a remote computer the command returns a certificate whose FriendlyName is empty, although the certificate in the remote store has one and the command's own Name property carries it. PowerShell remoting rebuilds the X509Certificate2 on the calling side from its raw bytes, and the friendly name is a property of the store entry rather than of the certificate, so it does not survive the trip - a remote note property of the same name does not either, which is why the code already exposes it as Name. New-DbaComputerCertificate returns this object for remote computers, so its documented FriendlyName was empty there too, while local results had it.

The command now copies Name back into FriendlyName on the calling side when it arrives empty, so local and remote results carry the same properties.

Verified in the lab against a second computer on PowerShell 7.6 and 5.1: New-DbaComputerCertificate and Get-DbaComputerCertificate both return the friendly name for the remote host, and unchanged for localhost. The new test runs locally in CI, where no second computer exists, and pins that both properties carry the name.

(do Get-DbaComputerCertificate)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant