-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpiredcerts
More file actions
24 lines (18 loc) · 846 Bytes
/
expiredcerts
File metadata and controls
24 lines (18 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Import the required modules
Import-Module PSWorkflow
Import-Module PSWorkflowUtility
# Define the certificate store to use (LocalMachine or CurrentUser)
$store = 'LocalMachine'
# Create a workflow to list the expired certificates
Workflow List-ExpiredCertificates {
# Get the current date
$now = Get-Date
# Get the list of certificates from the specified store
$certificates = Get-ChildItem -Path "cert:\$store" | Where-Object { -not $_.PSIsContainer }
# Print the expired certificates
Write-Output "Expired certificates:"
Write-Output $certificates | Where-Object { $_.NotAfter -lt $now } | Select-Object -Property Subject, Issuer, NotAfter
}
# Start the workflow
List-ExpiredCertificates
# Stop-Workflow -InstanceId (Get-WorkflowInstance | Where-Object { $_.Name -eq 'List-ExpiredCertificates' }).InstanceId