Forum Discussion
This should be the last script:
##--------------- Discovery ------------------##
$pshost = Get-Host # Get the PowerShell Host.
$pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI.
$newsize = $pswindow.BufferSize # Get the UI's current Buffer Size.
$newsize.width = 800 # Set the new buffer's width to 800 columns.
$pswindow.buffersize = $newsize # Set the new Buffer Size as active.
$newsize = $pswindow.windowsize # Get the UI's current Window Size.
$newsize.width = 800 # Set the new Window Width to 800 columns.
$pswindow.windowsize = $newsize # Set the new Window Size as active.
$readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"
$localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"
$store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine )
$store.Open( $readOnly )
$store.Certificates `
| Select-Object { `
$_.Thumbprint + "##" `
+ $_.Issuer + "##" `
+ $_.Subject + $_.Issuer + $_.NotAfter + "##" `
+ "##" `
+ "cert.issuer=" + $_.Issuer `
+ "&cert.friendlyname=" + $_.FriendlyName `
+ "&cert.serialnumber=" + $_.SerialNumber `
+ "&cert.thumbprint=" + $_.Thumbprint `
+ "&cert.days=" + ($_.NotAfter - [datetime]::Today).Days `
+ "&cert.issuerby=" + (($_.Issuer -split ",") |? {$_ -like "CN=*"}) -replace "CN=" `
} `
| Format-Table -HideTableHeaders
----=================================================================================================----
Thanks,
Dom
Related Content
- 3 months ago
- 3 years ago