From 2a5f3754e78664d96529f18b9f7bebce6722c629 Mon Sep 17 00:00:00 2001 From: nitzmahone Date: Fri, 21 Aug 2015 13:37:29 -0700 Subject: [PATCH] added windows facts ansible_lastboot, ansible_uptime_seconds switched OS object to Get-CimInstance since we need a DateTime object for lastbootuptime --- windows/setup.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/windows/setup.ps1 b/windows/setup.ps1 index 32b4d865263..bd2f6ac8c76 100644 --- a/windows/setup.ps1 +++ b/windows/setup.ps1 @@ -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