title: How to register windows module's win_command output in ansible task
body: <p>I am trying to create an ansible task in a playbook that will run a windows batch command and register the output in a variable. Later this will be printed by ansible debug module. Here is what i have done so far.</p>
  
  <pre><code>---
  
   - name: verify port listening
     raw: netstat -na | find "8080" register=result
   - debug: msg="{{result}}"
     tags: mnc-verify
  </code></pre>
  
  <p>Then run my playbook with this</p>
  
  <pre><code>ansible-playbook -i hosts service.yml --tags "mnc-verify"
  </code></pre>
  
  <p>The error i get</p>
  
  <pre><code>fatal: [v0560a.vstage.co]: FAILED! =&gt; {"failed": true, "msg": "'result' is undefined"}
  </code></pre>
  
  <p>Could anyone help me please
  -Raf</p>