# win\_service\_info register

**URL:** <https://forum.ansible.com/t/win-service-info-register/34500>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [January 24, 2021, 1:08pm UTC](https://forum.ansible.com/t/win-service-info-register/34500 "2021-01-24T13:08:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [January 24, 2021, 1:08pm UTC](https://forum.ansible.com/t/win-service-info-register/34500/1 "2021-01-24T13:08:28Z")

</div>

Hi  
Trying to use win\_service\_info with a register.  
While the register is filled with multiple entries, i want to make sure all these are started.  
How to write the loop ?

- name: Find all services that start with ‘blabla’  
ansible.windows.win\_service\_info:  
name: blabla\*  
register: service

#Print everything

- name: Print service facts  
ansible.builtin.debug:  
var: service

#Print only the first one

- name: Print service facts  
ansible.builtin.debug:  
var: service.services[0].name

**- name: make sure service is started**  
**win\_service:**  
**name: ‘service.services[{{ item }}].name’**  
**state: started**  
**with\_items: service.services.index ?**

Thanks!

cc @jborean93

---

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [January 24, 2021, 1:43pm UTC](https://forum.ansible.com/t/win-service-info-register/34500/2 "2021-01-24T13:43:54Z")

</div>

Hi Jordan, can you please assist here ?

---

<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:** [January 24, 2021, 7:27pm UTC](https://forum.ansible.com/t/win-service-info-register/34500/3 "2021-01-24T19:27:51Z")

</div>

Just loop the services entry and then your item is item.name.

- win\_service:  
name: ‘{{ item.name }}’  
state: started  
with\_items: ‘{{ service.services }}’

This works because service.services is a list that contains a dictionary so you are looping each entry and then getting the name key in that dict.

---

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [January 25, 2021, 11:52am UTC](https://forum.ansible.com/t/win-service-info-register/34500/4 "2021-01-25T11:52:30Z")

</div>

Thank you!  
I wonder why i didn’t try it…

---

<div class="post-metadata">

**Author:** ![ftpk](https://avatars.discourse-cdn.com/v4/letter/f/8e8cbc/32.png) [@ftpk](https://forum.ansible.com/u/ftpk)\
**Post date:** [September 30, 2022, 12:40am UTC](https://forum.ansible.com/t/win-service-info-register/34500/5 "2022-09-30T00:40:50Z")

</div>

HI Jordan,

I am wondering how I could modify the above code to only start when a service exist with out ignoring errors as an option.
