Вы можете сделать это с powershell:
myscript.ps1:
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
Stop-Process -Name Explorer
Ansible playbook:
- name: example copying file with owner and permissions
copy:
src: myscript.ps1
dest: myscript.ps1
- name: Run ps1 script in privileged mode
hosts: "{{ my_hosts }}"
become_method: runas
vars:
ansible_become_password: passwordhere
tasks:
- win_shell: '.\myscript.ps1'
become: yes
become_user: Administrator
- name: Create new user
win_user:
name: someuser
password: somepassword
state: present
groups:
- Users