powershell - retrieve certificate information on remote computer
please help... i'm trying below script work. i'm new powershell world , appreciate can me fix this.
$remoteserverlist = "server1","server2" $remotewebcertlist = @() foreach ($server in $remoteserverlist) { try { $username = "username" $password = "password" $cred = new-object -typename system.management.automation.pscredential -argumentlist $username, $password $s = new-pssession -computername $server -credential $cred $remoteservercertlist += invoke-command -session $s -scriptblock { $store = new-object system.security.cryptography.x509certificates.x509store("my","localmachine") $store.open("readonly") $store.certificates | select-object *,@{name="pscomputername"} } remove-pssession $s } catch { write-host "error connecting remote server $server, please verify connectivity , permissions" } $remotewebcertlist += $remoteservercertlist }
i'm getting error message below.
a mandatory entry expression missing.
+ categoryinfo : invalidargument: (:) [select-object], notsupportedexception
+ fullyqualifiederrorid : dictionarykeymandatoryentry,microsoft.powershell.commands.selectobjectcommand
+ pscomputername : server1
thanks
this have do:
$remoteserverlist = "server1", "server2" $username = "username" $cred = get-credential $username $remoteserverlist| foreach-object{ invoke-command -scriptblock { get-childitem cert:\localmachine\my} -computername $_ -credential $cred } | select pscomputername, issuer, notafter
the above identical in results trying uses bits correctly , more easily.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment