From 387759ada62ad43fce9acce6e8bf4160897b6ebd Mon Sep 17 00:00:00 2001 From: Trond Hindenes Date: Tue, 22 Jul 2014 01:38:46 +0200 Subject: [PATCH] win_setup improvements: Correcly outputs ansible_totalmem on computers with multiple ram chips --- library/windows/setup.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/windows/setup.ps1 b/library/windows/setup.ps1 index 8c1a45c82b..bd4718310d 100644 --- a/library/windows/setup.ps1 +++ b/library/windows/setup.ps1 @@ -26,7 +26,10 @@ $result = New-Object psobject @{ }; $osversion = [Environment]::OSVersion -$memory = Get-WmiObject win32_Physicalmemory +$memory = @() +$memory += Get-WmiObject win32_Physicalmemory +$capacity = 0 +$memory | foreach {$capacity += $_.Capacity} $netcfg = Get-WmiObject win32_NetworkAdapterConfiguration Set-Attr $result.ansible_facts "ansible_hostname" $env:COMPUTERNAME; @@ -36,7 +39,7 @@ Set-Attr $result.ansible_facts "ansible_os_family" "Windows" Set-Attr $result.ansible_facts "ansible_distribution" $osversion.VersionString Set-Attr $result.ansible_facts "ansible_distribution_version" $osversion.Version.ToString() -Set-Attr $result.ansible_facts "ansible_totalmem" $memory.Capacity.ToString() +Set-Attr $result.ansible_facts "ansible_totalmem" $capacity $ips = @() Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }