0

I would like to know how to view all certificates under a different user using MMC so that I can save all the certificate details in an excel file. I have all the necessary credentials, username and password, of the other user I want to log in into in MMC but I have trouble executing the code to view the certificate information.

I only know how to view certificate with the current user and to save that information in an csv file. But I don't know how to execute the code using a different MMC credential.

This is what I've tried to view the "Current User" certificate:

# Set-Location Cert
Get-ChildItem –Recurse |
    Select subject, issuer, thumbprint, notbefore, notafter |
    Export-Csv C:\Temp\temp.csv

Please let me know if you could help me revise the code above by using a different user credential in MMC so I can view that user's certificate.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
123testing123
  • 57
  • 2
  • 10
  • Possible duplicate of [Getting local machine and all user certificates with PowerShell](https://stackoverflow.com/questions/18712066/getting-local-machine-and-all-user-certificates-with-powershell) – Drew Jul 22 '19 at 04:00
  • Its not a duplicate. I want to know how. – 123testing123 Jul 22 '19 at 04:11

1 Answers1

1

Try this in an Administrator Powershell console (substituting your UserName and password, of course):

$Cred = New-Object System.Management.Automation.Credential('UserName',(ConvertTo-SecureString 'password' -AsPlainText -Force))
Start-Process powershell -Credential $cred -ArgumentList '-command &{Get-ChildItem cert:\ -Recurse | Select subject, issuer, thumbprint, notbefore, notafter | Export-CSV C:\Temp\temp.csv}' -Wait -WorkingDirectory 'C:\Windows\System32'
Rich Moss
  • 2,195
  • 1
  • 13
  • 18
  • I get to the credentials and it works but the powershell crashes on me the moment I try to type something. – 123testing123 Jul 23 '19 at 02:27
  • Sorry for the bugs - I copied this code from a working script and introduced a typo and had a [missing parameter](https://stackoverflow.com/questions/7319658/start-process-raises-an-error-when-providing-credentials-possible-bug) `-WorkingDirectory`. Please retry with the edited version. – Rich Moss Jul 23 '19 at 18:05
  • 1
    we needed PSCredential because we were getting an error finding the Credential object. `$cred = New-Object System.Management.Automation.PSCredential($username,$password)`. ref: https://social.technet.microsoft.com/Forums/en-US/38980183-9a6f-403c-a4e5-a2fd90fdfe3c/i-cant-seem-to-use-system-management-automation-no-matter-what-i-try?forum=winserverpowershell – TeaBaerd Feb 28 '22 at 21:47