Get-DbaComputerCertificate - Keep the friendly name of certificates on remote computers - #10668
Open
andreasjordan wants to merge 1 commit into
Open
Get-DbaComputerCertificate - Keep the friendly name of certificates on remote computers#10668andreasjordan wants to merge 1 commit into
andreasjordan wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For a remote computer,
Get-DbaComputerCertificatereturns certificates whoseFriendlyNameis empty, although the certificate in the remote store has one and the command's ownNameproperty carries it.New-DbaComputerCertificatereturns this object for remote computers, so its documentedFriendlyNamewas empty there too, while local results had it.Mechanism
PowerShell remoting rebuilds the
X509Certificate2on 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 asName.What changed
The command copies
Nameback intoFriendlyNameon the calling side when it arrives empty. Local and remote results now carry the same properties; nothing changes for localhost. The.OUTPUTSnote onNamesays so.Tests
NameandFriendlyNamecarry the friendly name. It runs locally in CI, where no second computer exists.Get-DbaComputerCertificateandNew-DbaComputerCertificateagainst 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.ps1green through the testing-dbatools harness.created by Claude and reviewed by Andreas Jordan
🤖 Generated with Claude Code