# Ansible Playbook Task - to upgrade azure vm from 2016 to 2022

**URL:** <https://forum.ansible.com/t/ansible-playbook-task-to-upgrade-azure-vm-from-2016-to-2022/3547>\
**Category:** Get Help\
**Tags:** azure, windows, playbook, collections\
**Created:** [January 31, 2024, 4:13pm UTC](https://forum.ansible.com/t/ansible-playbook-task-to-upgrade-azure-vm-from-2016-to-2022/3547 "2024-01-31T16:13:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greta\_sh](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@greta\_sh](https://forum.ansible.com/u/greta_sh)\
**Post date:** [January 31, 2024, 4:13pm UTC](https://forum.ansible.com/t/ansible-playbook-task-to-upgrade-azure-vm-from-2016-to-2022/3547/1 "2024-01-31T16:13:37Z")

</div>

Hi,

I need any advise, i am trying to upgrade the azure windows virtual machine from Windows 2016 Datacenter to Windows 2022 Datacenter (Desktop Experience).  
I included the task:

- name: Upgrade the server (Disk E)  
win\_shell: .\setup.exe /auto upgrade /dynamicupdate disable --install-image “Windows Server 2022 Datacenter (Desktop Experience)”  
args:  
chdir: E:\Windows Server 2022  
become: yes  
become\_user: “{{ansible\_user}}”  
become\_method: runas

I am following the steps: [Windows in-place upgrade - Azure Virtual Machines](https://learn.microsoft.com/en-us/azure/virtual-machines/windows-in-place-upgrade#powershell-script)  
So i am trying to automate it.

When i run the playbook with this task, i get the following output and the upgrade isn’t done.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/5/593b13a9475fcda888353c8cca3a28293fab1570.png)

Any idea please what i need to change?  
Thanks
