代码之家  ›  专栏  ›  技术社区  ›  itye1970

如何使用Azure Powershell运行手册检查Azure VM中的SSL过期

  •  0
  • itye1970  · 技术社区  · 3 年前

    我需要检查订阅中所有Azure VM的SSL过期情况,在Azure中使用powershell和Runbook这样做的最佳方式是什么?

    0 回复  |  直到 3 年前
        1
  •  0
  •   Bhargavi Annadevara    3 年前

    假设你的证书存储在 Azure Key Vault ,你可以使用 Get-AzKeyVault Get-AzKeyVaultCertificate Cmdlet来编写PS脚本,检查您的任何证书是否即将过期。以下是一个PS片段示例:

    $Result = @()
    
    # Get all certificates from all Key Vaults in your Subscription
    $AllCerts = Get-AzKeyVault | Get-AzKeyVaultCertificate
    
    # Check for certs expiring in the next 90 days
    foreach($Cert in $AllCerts)
    {
        if($Cert.Expires -lt ((Get-Date).AddDays(90)))
        {
            $Result += $Cert
        }
    }
    
    $Result | ft -Property Name, VaultName, Enabled, Created, NotBefore, Updated, Expires, Id
    

    样本输出:

    Sample Output

    完成后,您可以在 PowerShell runbook .一定要注意配置 Run As account 在Azure Automation中,您可以使用runbook管理Azure资源。