# Connecting to a WinRM host with different credentials?

**URL:** <https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 23, 2020, 4:42am UTC](https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305 "2020-02-23T04:42:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_York](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@Dave\_York](https://forum.ansible.com/u/Dave_York)\
**Post date:** [February 23, 2020, 4:42am UTC](https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305/1 "2020-02-23T04:42:00Z")

</div>

I have a playbook in which I want to create a random password and use it later to connect to a windows box over WinRM

I’ve generated a random password like this:

- name: Generate a temporary random password for new host  
set\_fact:  
randopass: “{{ lookup(‘password’, ‘/dev/null length=15 chars=ascii\_letters’) }}”

I set the admin password with vmware\_guest os customization:  
customization:

password: ‘{{ randopass }}’  
timezone: 004

Then - I’m trying to use:

- hosts: ‘[hostname.internal.domain.com](http://hostname.internal.domain.com)’  
connection: winrm  
port: 5985  
remote\_user: Administrator  
remote\_pass: ‘{{ randopass }}’  
gather\_facts: yes

I’ve tried “remote\_password, remote\_pass, ansible\_pass, ansible\_password” and I get an error message like this:

ERROR! ‘remote\_pass’ is not a valid attribute for a Play

What can I use for this part of the play to connect as a different user/password?

I’m using ansible tower if it matters

---

<div class="post-metadata">

**Author:** ![Tom\_Van\_de\_Velde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tom_van_de_velde/32/10548_2.png) [@Tom\_Van\_de\_Velde](https://forum.ansible.com/u/Tom_Van_de_Velde)\
**Post date:** [February 23, 2020, 10:13am UTC](https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305/2 "2020-02-23T10:13:06Z")

</div>

Hi,

According to doc it should be

```auto
ansible_user: LocalUsername
ansible_password: Password
ansible_connection: winrm
ansible_winrm_transport: basic

```

Regards

Tom

---

<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:** [February 23, 2020, 6:52pm UTC](https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305/3 "2020-02-23T18:52:46Z")

</div>

Further to the above, those are variables and not attributes you can set on a play. You need to set them under your the vars key or just add them using add\_host in the previous play.

---

<div class="post-metadata">

**Author:** ![Dave\_York](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@Dave\_York](https://forum.ansible.com/u/Dave_York)\
**Post date:** [February 24, 2020, 4:07am UTC](https://forum.ansible.com/t/connecting-to-a-winrm-host-with-different-credentials/32305/4 "2020-02-24T04:07:44Z")

</div>

That was what I was looking for. Thanks Jordan/Tom
