Executing practically the same command but remotely delivers no results in Powershell.
This delivers empty lines:
$certificates = Invoke-Command -ComputerName $computername -ScriptBlock {
Get-ChildItem Cert:\LocalMachine\My
}
foreach ($certificate in $certificates)
{
$certificate.FriendlyName
}
meanwhile this script locally on the remote computer delivers the desired results:
$certificates = Get-ChildItem Cert:\LocalMachine\My
foreach ($certificate in $certificates)
{
$certificate.FriendlyName
}
I use the Invoke-Command in another script with certificates and works perfectly fine. All the other properties except FriendlyName work perfectly fine. I added all the friendly names on the certificates today, maybe the computer I run invoke-command from hasn't caught on yet?
Found the solution. Had to do this pipeline thingy for whatever reason
$certificates = Invoke-Command -ComputerName $computername -ScriptBlock {
Get-ChildItem Cert:\LocalMachine\My | Select FriendlyName
}
foreach ($certificate in $certificates)
{
$certificate.FriendlyName
}