1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #8833 from jhawkesworth/win_facts_powershell_version_and_winrm_cert_expiry_revised

Revised additions to windows facts
This commit is contained in:
Chris Church 2014-08-31 11:49:34 -04:00
commit b068155a43

View file

@ -66,4 +66,13 @@ $ips = @()
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
$psversion = $PSVersionTable.PSVersion.Major
$winrm_cert_expiry = Get-ChildItem -Path Cert:\LocalMachine\My | where Subject -EQ "CN=$env:COMPUTERNAME" | select NotAfter
Set-Attr $result.ansible_facts "ansible_powershell_version" $psversion
if ($winrm_cert_expiry)
{
Set-Attr $result.ansible_facts "ansible_winrm_certificate_expires" $winrm_cert_expiry.NotAfter.ToString("yyyy-MM-dd HH:mm:ss")
}
Exit-Json $result;