Run powershell script on Windows servers which require Powershell to be run with admin privilages

73 views
Skip to first unread message

Ashish Vijay

unread,
May 22, 2017, 10:19:12 AM5/22/17
to Ansible Project
Hello All,

I want to execute one powershell script on few target servers which require powershell to be run as administrator. I am getting access denied error when i try with normal playbook.

- name: Install software on Wndows Remote server.
  hosts: all
  tasks:

  - name: copy script
    win_copy:
      src: /tmp/install.ps1
      dest: c:\temp\install.ps1

  - name: run a powershell script
    script: install.ps1 -Install -arg '{{ ARGLIST }}'
    register: out1
  - debug: var=out1


I am getting access denied error when i try to execute this playbook.

Trond Hindenes

unread,
May 22, 2017, 1:40:27 PM5/22/17
to Ansible Project
There's no such thing as UAT/"run as admin" when using WinRM (which Ansible does). What does your script do, exactly?

Jordan Borean

unread,
May 22, 2017, 4:07:45 PM5/22/17
to Ansible Project
I could be wrong but when calling script it looks locally on the Ansible box and not the windows one. Can you specify your script without using win_copy and see what happens?

J Hawkesworth

unread,
May 23, 2017, 12:41:18 PM5/23/17
to Ansible Project

hosts: all

will try and run on all hosts in your inventory.  These are unlikely to be all windows hosts.

I suggest limiting just to windows host to start with. -l option.

Also how are you running the playbook? what command line is used?  where is 'ARGLIST' defined?

Jon
Reply all
Reply to author
Forward
0 new messages