Get-RemoteCertificates.ps1
19 Sep 2025Description
Purpose
No synopsis provided.
Detailed Description
No detailed description provided.
Usage
No usage examples provided.
Notes
No additional notes.
Script
function Get-RemoteCertificates {
param (
[Parameter(Mandatory = $true)]
[string]$ComputerName,
[Parameter(Mandatory = $true)]
[pscredential]$Credential
)
$scriptBlock = {
# Retrieve all certificates from the Local Machine's Personal store
$certificates = Get-ChildItem -Path Cert:\LocalMachine\My
if ($certificates.Count -eq 0) {
Write-Output "No certificates found in the Local Machine's Personal store."
return $null
}
# Prepare a list of certificate details
$certDetailsList = $certificates | ForEach-Object {
$cert = $_
$eku = $cert.EnhancedKeyUsageList | Where-Object { $_.FriendlyName -eq "Server Authentication" }
[PSCustomObject]@{
Subject = $cert.Subject
Issuer = $cert.Issuer
Thumbprint = $cert.Thumbprint
NotBefore = $cert.NotBefore
NotAfter = $cert.NotAfter
HasServerAuthEKU = ($eku -ne $null)
}
}
return $certDetailsList
}
$certDetailsList = Invoke-Command -ComputerName $ComputerName -ScriptBlock $scriptBlock -Credential $Credential
return $certDetailsList
}
# Example usage
# $computerName = "RemoteServerFQDN"
# $credential = Get-Credential
# $certificates = Get-RemoteCertificates -ComputerName $computerName -Credential $credential
# $certificates | Format-Table -AutoSize
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.