#requires -version 3.0
###############################################################################
# Copyright (c) 201x-2018 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Version 1.00
#
# Get a list of certificates installed in the local certificate store remotely
# across 1 or more machines (Certificates \ Personal \ Certificates)
#
# REQUIREMENTS: PowerShell Remoting enabled on target hosts
#
###############################################################################
#get Lync/Skype4b Registrar pools and corresponding nodes in this example
$pools = (Get-CsService -Registrar | ? SiteId -eq “Site:CH”).PoolFqdn
$nodes = $pools | % { Get-CsComputer -Pool $_ }
#retrieve Fqdn of nodes or manually assign an array of host names
$computers = $nodes.Fqdn
$arr = @()
foreach ($server in $computers)
{
$results = Invoke-Command -ComputerName $server -Command {
dir Cert:\LocalMachine\My |
Select-Object @{l=’Subject’;
e={($_.Subject.Split(‘,’))[0].SubString(3)}},
NotBefore,NotAfter,FriendlyName,Thumbprint,
@{l=’Issuer’;e={($_.Issuer.Split(‘,’))[0].SubString(3)}}
#AlternativeNames
}
$pool = “-”
$idx = [array]::IndexOf($computers, $server)
if ($idx -ne -1)
{
$pool = $nodes[$idx].Pool
}
$results | Add-Member -MemberType NoteProperty -Name Pool -Value $pool
$results | % {
$_.PsComputerName = $_.PsComputerName.SubString(0,$_.PsComputerName.IndexOf(‘.’))
}
$arr += $results
}
$arr | ogv -Title “www.leedesmond.com #powershell Local Certificate Store Inventory (Windows) ($($arr.count))”