# Powershell script not completely executing...

**URL:** <https://forum.ansible.com/t/powershell-script-not-completely-executing/18905>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 30, 2015, 5:34pm UTC](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905 "2015-07-30T17:34:24Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![O\_haya](https://avatars.discourse-cdn.com/v4/letter/o/ea666f/32.png) [@O\_haya](https://forum.ansible.com/u/O_haya)\
**Post date:** [August 3, 2015, 12:43pm UTC](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905/21 "2015-08-03T12:43:51Z")

</div>

Hi,

Thanks for the comments/suggestions.

Re. the “echo” problem, I think that I wasn’t being clear. What I wanted to do was to do the “echo $(whoami)” and have the output of that re-directed to a file, somewhere, in order to try to test/understand what user the commands that are being run under the “raw” module are running. As I said, I’m guessing that they are not running under the same user as the commands that are run under the script module. But then, when I tried the echo, running under raw module, outputting to the filesystem, it failed with “access denied”, even if I tried outputting to the E: drive somewhere.

So, it’s a “catch-22” situation: It seems like commands running under the raw module are running under a different (maybe “no”) user than commands running inside a ps1 running under a script module, but my test to try to find out which user that is is failing.

Re. your comments in your last paragraph: I agree that there’s a lot going on, but if you recall, I already had these same set of commands (script) running Chef previously, and am trying to see how far I could get with replicating what I was able to do with Chef but using Ansible instead, as I think that Ansible’s push model fits our use case better.

Thanks again,  
Jim

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [August 3, 2015, 2:45pm UTC](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905/22 "2015-08-03T14:45:13Z")

</div>

I don’t know too much about the “raw” module on WIndows as I never use it, but I can assure you it’s running under the use specified in hosts. There’s no magic there. The problem seems to be related to running “echo” which is a cmd powershell doesn’t understand. from the looks of it raw implements a powershell host.

if you want to output the current user you could do something like  
ansible -m raw -a ‘set-content C:/currentuser.txt -value $(whoami)’ all

and to read it:  
ansible -m raw -a ‘get-content C:/currentuser.txt’ all

---

<div class="post-metadata">

**Author:** ![ericschradermb](https://avatars.discourse-cdn.com/v4/letter/e/46a35a/32.png) [@ericschradermb](https://forum.ansible.com/u/ericschradermb)\
**Post date:** [January 11, 2016, 6:44am UTC](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905/23 "2016-01-11T06:44:57Z")

</div>

I am just learning Ansible myself for SharePoint installations on Windows. I am very very familiar with SharePoint on Windows. Any updates on the Ansible process?

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [January 12, 2016, 10:01pm UTC](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905/24 "2016-01-12T22:01:42Z")

</div>

Not sure what you’re referring to?

[Previous page](https://forum.ansible.com/t/powershell-script-not-completely-executing/18905.md?page=1)
