# Ansible Windows: Add account to group administrators FR/US

**URL:** <https://forum.ansible.com/t/ansible-windows-add-account-to-group-administrators-fr-us/24932>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 8, 2017, 2:22pm UTC](https://forum.ansible.com/t/ansible-windows-add-account-to-group-administrators-fr-us/24932 "2017-07-08T14:22:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanchfanch44](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@fanchfanch44](https://forum.ansible.com/u/fanchfanch44)\
**Post date:** [July 8, 2017, 2:22pm UTC](https://forum.ansible.com/t/ansible-windows-add-account-to-group-administrators-fr-us/24932/1 "2017-07-08T14:22:33Z")

</div>

Hello,

I’m starting with Ansible. I would like to know in a playbook how to test if the windows computer is in version FR or US. Following the test, I would add account users to the local “Administrators” or “Administrateurs” group.

By default:

- name: Add a user  
Hosts: windows\_tst  
Gather\_facts: false  
tasks:
- name: Add User  
win\_user:  
Name: admintest  
Password: “mypassword”  
State: present  
Groups: Administrators

But if I am on a computer in French, the group administrors does not exist.

How I can solve this problem.

Thank you in advance for your assistance.  
Regards

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [July 10, 2017, 8:41pm UTC](https://forum.ansible.com/t/ansible-windows-add-account-to-group-administrators-fr-us/24932/2 "2017-07-10T20:41:56Z")

</div>

Hey

One thing you can do is use the win\_region module [https://docs.ansible.com/ansible/win\_region\_module.html](https://docs.ansible.com/ansible/win_region_module.html) to change the region of your hosts to a common value. If this isn’t what you can do, you can also run an adhoc command to determine the group name based on the SID. Give the below tasks a shot and see if it returns what you are looking for.

> - name: get group name from sid  
> win\_command: powershell.exe “((New-Object System.Security.Principal.SecurityIdentifier(‘S-1-5-32-544’)).Translate([System.Security.Principal.NTAccount]).Value -split ‘\’)[1]”  
> register: admin\_group

> - debug:  
> var: admin\_group.stdout\_lines[0]

It looks up the group name based on the SID ‘S-1-5-32-544’ which is the default SID for the local administrators group and should be consistent across all Windows OS’.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![fanchfanch44](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@fanchfanch44](https://forum.ansible.com/u/fanchfanch44)\
**Post date:** [July 11, 2017, 2:09pm UTC](https://forum.ansible.com/t/ansible-windows-add-account-to-group-administrators-fr-us/24932/3 "2017-07-11T14:09:22Z")

</div>

Hello Jordan,

Thank you very mutch. I had the same raissonement with a custom script.  
Yesterday, i created a specifical script to ckeck a groups.

function Get-AdministratorsGroupName {

$LocalGroup = @(‘Administrators’, ‘Administrateurs’, ‘Domain Admins’)

foreach ($Group in $LocalGroup){  
Try{  
if(([adsi]“WinNT://./$Group,group”).psbase.Invoke(‘Members’)){  
return $Group  
}  
} catch {}  
}  
}

Get-AdministratorsGroupName

Regards
