# Convert PowerShell script to Ansible task

**URL:** <https://forum.ansible.com/t/convert-powershell-script-to-ansible-task/32121>\
**Category:** Ansible Project\
**Created:** [February 3, 2020, 12:45pm UTC](https://forum.ansible.com/t/convert-powershell-script-to-ansible-task/32121 "2020-02-03T12:45:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Rawat](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Rahul\_Rawat](https://forum.ansible.com/u/Rahul_Rawat)\
**Post date:** [February 3, 2020, 12:45pm UTC](https://forum.ansible.com/t/convert-powershell-script-to-ansible-task/32121/1 "2020-02-03T12:45:02Z")

</div>

Hi,

I have to convert PowerShell Script (using if else condition) into anisble task.  
How we can work with condition in ansible tasks.

Here is my powershell script.

$officeInstalled = Get-WmiObject win32\_product | where { $\_.Name -like “Microsoft Office\*” } | select Name,Version

if ($officeInstalled -is [array])  
{

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 3, 2020, 12:58pm UTC](https://forum.ansible.com/t/convert-powershell-script-to-ansible-task/32121/2 "2020-02-03T12:58:07Z")

</div>

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_conditionals.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html)
