---
- name: Optimize Powershell
hosts: all
gather_facts: yes
tasks:
- name: Copy script
win_copy
src: "{{fileserver}}\\Open\\Scripts\\Optimize-Powershell.ps1"
dest: C:\temp\Optimize-Powershell.ps1
remote_src: yes
- name: Copy PsExec
win_copy:
src: "{{fileserver}}\\Open\\PSTools\\PsExec.exe"
dest: c:\temp\psexec.exe
remote_src: yes
- name: Run script through psexec
win_psexec:
command: "powershell.exe -executionpolicy bypass -noninteractive -nologo -file C:\\temp\\Optimize-Powershell.ps1"
executable: C:\temp\psexec.exe
elevated: yes
nobanner: yes
interactive: yes
username: "{{adminuser}}"
password: "{{adminpass}}"