Skip to content

Commit

Permalink
Merge pull request ansible#8833 from jhawkesworth/win_facts_powershel…
Browse files Browse the repository at this point in the history
…l_version_and_winrm_cert_expiry_revised

Revised additions to windows facts
  • Loading branch information
cchurch committed Aug 31, 2014
2 parents 69e7999 + e4b80dd commit b068155
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/windows/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit b068155

Please sign in to comment.