Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oanderoficial/monitor_certificate_validity
Monitorar validade de certificados no Windows.
https://github.com/oanderoficial/monitor_certificate_validity
certificate powershell powershell-script windows
Last synced: 30 days ago
JSON representation
Monitorar validade de certificados no Windows.
- Host: GitHub
- URL: https://github.com/oanderoficial/monitor_certificate_validity
- Owner: oanderoficial
- Created: 2024-10-18T15:58:42.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-29T12:24:51.000Z (3 months ago)
- Last Synced: 2024-10-29T14:51:59.611Z (3 months ago)
- Topics: certificate, powershell, powershell-script, windows
- Language: PowerShell
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Monitor certificate validity
Monitorar validade de certificados no Windows.
Comandos úteis:
* Listar certificados pessoais
```ps1
Get-ChildItem Cert:\LocalMachine\My
```* Listar certificados de raiz
```ps1
Get-ChildItem Cert:\LocalMachine\Root
```* Listar certificados de autoridades de certificação
```ps1
Get-ChildItem Cert:\LocalMachine\CA
```* Listar todos os certificados da máquina local
```ps1
Get-ChildItem Cert:\LocalMachine
``````ps1
# Configura a política de execução para a sessão atual
Set-ExecutionPolicy RemoteSigned -Scope Process -Force$certificado = "Cert:\LocalMachine\Root\AD7E1C28B064EF8F6003402014C3D0E3370EB58A"
$logsave = "C:\Zabbix\scripts\cert.log"
$comando = Get-Item $certificado
$expirar = $comando.NotAfter
$diasrestantes = ($expirar - (Get-Date)).Days
$retorna = $diasrestantes
Set-Content -Path $logsave -Value $retorna
``````ps1
$certificado = "Cert:\CurrentUser\My\AD7E1C28B064EF8F6003402014C3D0E3370EB58A"
$logsave = "C:\Apps\Cert\log.txt"$comando = Get-Item $certificado
$expirar =$comando.NotAfter
$diasrestantes = ($expirar - (Get-Date)).Daysif ($diasrestantes -le 30) {
$retorna = 1
} else{
$retorna = 0
}Set-Content -Path $logsave -Value $retorna
```Implementando no Zabbix
Criação do item:
![image](https://github.com/user-attachments/assets/1c54b4c4-853e-4be8-900c-f214b2f72846)
Trigger de exemplo:
![image](https://github.com/user-attachments/assets/347c43be-a283-4e07-a670-25dbd29aacba)