From 1a4804cc6052f76deead6eb6799b2b09b88a05cb Mon Sep 17 00:00:00 2001 From: nitzmahone Date: Wed, 29 Jun 2016 17:32:52 -0700 Subject: [PATCH] fixes to windows setup coerce multi-socket win32_processor to a single value WindowsIdentity.Label doesn't exist on .NET 4.0 --- lib/ansible/modules/windows/setup.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/windows/setup.ps1 b/lib/ansible/modules/windows/setup.ps1 index 08c63fec947..d1268b976c4 100644 --- a/lib/ansible/modules/windows/setup.ps1 +++ b/lib/ansible/modules/windows/setup.ps1 @@ -56,6 +56,9 @@ $win32_os = Get-CimInstance Win32_OperatingSystem $win32_cs = Get-CimInstance Win32_ComputerSystem $win32_bios = Get-CimInstance Win32_Bios $win32_cpu = Get-CimInstance Win32_Processor +If ($win32_cpu -is [array]) { # multi-socket, pick first + $win32_cpu = $win32_cpu[0] +} $ip_props = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties() $osversion = [Environment]::OSVersion @@ -122,7 +125,7 @@ Set-Attr $result.ansible_facts "ansible_owner_name" ([string] $win32_cs.PrimaryO Set-Attr $result.ansible_facts "ansible_owner_contact" ([string] $win32_cs.PrimaryOwnerContact) Set-Attr $result.ansible_facts "ansible_user_dir" $env:userprofile -Set-Attr $result.ansible_facts "ansible_user_gecos" ([string] $user.Label) +Set-Attr $result.ansible_facts "ansible_user_gecos" "" # Win32_UserAccount.FullName is probably the right thing here, but it can be expensive to get on large domains Set-Attr $result.ansible_facts "ansible_user_id" $env:username Set-Attr $result.ansible_facts "ansible_user_uid" ([int] $user.User.Value.Substring(42)) Set-Attr $result.ansible_facts "ansible_user_sid" $user.User.Value