Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Certificate Expiration checking

$
0
0
$CSV = Import-Csv C:\scripts\Servers.csv
$CSV | ForEach { 
			write-output $_.ServerList
			#Number of days to look for expiring certificates
			$threshold = 120
			#Set deadline date
			$deadline = (Get-Date).AddDays($threshold)
			$store=new-object System.Security.Cryptography.X509Certificates.X509Store("\\$_.ServerList\my","LocalMachine")
			$store.open("ReadOnly")
			$store.certificates | % {
			If ($_.NotAfter -lt $deadline) {
				$_ | Select Issuer, Subject, NotAfter, @{Label="ExpiresIn"; Expression={($_.NotAfter - (Get-Date)).Days}}
											}
									}
				}

I am running against the few servers in CSV file and i get following error. Any idea?

Exception calling "Open" with "1" argument(s): "The network path was not found.
"
At C:\scripts\test01.ps1:13 char:4
+             $store.open("ReadOnly")
+             ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CryptographicException


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>