I have the following script which brings back any certificates on the local machine needed for our VPN client and shows the expiry date:
$asset = $env:COMPUTERNAME
Set-Location cert:\LocalMachine\My
Write-Host = "Asset ID:"$asset
Get-ChildItem -Recurse cert: | select subject, notafter
write-host "`n"
Read-Host "Press any key to exit..."
(Get-Host).SetShouldExit(0)
It runs perfectly on my local machine, bring back the following:
Subject NotAfter
------- --------
CN=HW008551D.hca.local 21/07/2018 09:46:08
Is there a way I can run this on a remote machine, which looks at that machines certificate store rather than the local machines?
I have tried a few different methods but unable to find anything that works
Invoke-Command -computername $asset -scriptblock {Get-ChildItem -Recurse cert: | select subject, notafter}