Link to home
Start Free TrialLog in
Avatar of MattyS82
MattyS82

asked on

PowerShell Script

Hi,

Running the Get-ChildItem -Recurse Cert: in powershell gives me a list of installed certificates on the server.

My question is. How to I script this to get the certificates installed on several servers? I.e if I have a list of servers I want to query in a text file. Basically, how do I run this command on a list of servers?
Avatar of becraig
becraig
Flag of United States of America image

gc serverlist.txt  | foreach-object {invoke-command -computername $_ -scriptblock {gci cert:\LocalMachine\My }}
SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Subsun,

There is an unresolved reference to $Search in the Write-Host message ;-). But the script works nevertheless.
Ha.. I forgot to remove it. Thanks for checking...I just modified the script which I had done for another question #a38476902.. :-)

@MattyS82, You can modify line 16 to..
else {Write-Host "$server Does not contain any certs" -B Yellow -F Red}
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MattyS82
MattyS82

ASKER

Thank you for your efforts. This is greatly appreciated and it was way beyond my knowledge of powershell.