added windows facts ansible_lastboot, ansible_uptime_seconds

switched OS object to Get-CimInstance since we need a DateTime object for lastbootuptime
This commit is contained in:
nitzmahone 2015-08-21 13:37:29 -07:00 committed by Matt Clay
parent 1102afed43
commit 51154a6991

View file

@ -25,7 +25,7 @@ $result = New-Object psobject @{
changed = $false
};
$win32_os = Get-WmiObject Win32_OperatingSystem
$win32_os = Get-CimInstance Win32_OperatingSystem
$osversion = [Environment]::OSVersion
$memory = @()
$memory += Get-WmiObject win32_Physicalmemory
@ -66,6 +66,9 @@ Set-Attr $result.ansible_facts "ansible_distribution_version" $osversion.Version
Set-Attr $result.ansible_facts "ansible_totalmem" $capacity
Set-Attr $result.ansible_facts "ansible_lastboot" $win32_os.lastbootuptime.ToString("u")
Set-Attr $result.ansible_facts "ansible_uptime_seconds" $([System.Convert]::ToInt64($(Get-Date).Subtract($win32_os.lastbootuptime).TotalSeconds))
$ips = @()
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips