# PowerShell script help

**URL:** <https://forum.ansible.com/t/powershell-script-help/28818>\
**Category:** Ansible Project\
**Created:** [October 18, 2018, 1:42pm UTC](https://forum.ansible.com/t/powershell-script-help/28818 "2018-10-18T13:42:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [October 18, 2018, 1:42pm UTC](https://forum.ansible.com/t/powershell-script-help/28818/1 "2018-10-18T13:42:41Z")

</div>

Hi, all.

I’ve created a playbook to run a PowerShell script. The script is already copied to the target system (but also exists on the Ansible server). It must be run with the following argument:

-ConsoleTitle “Dell Command | Update”

I’ve tried every module I can think of, with every way to add the argument that I can think of, but can’t get the playbook to run successfully. Help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 18, 2018, 7:30pm UTC](https://forum.ansible.com/t/powershell-script-help/28818/2 "2018-10-18T19:30:31Z")

</div>

Use win\_command to call the script like you would locally.

`

- win\_command: powershell.exe -ExecutionPolicy Bypass -File C:\path\to\script.ps1 -ConsoleTitle “Dell Command | Update”

`

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [October 18, 2018, 8:27pm UTC](https://forum.ansible.com/t/powershell-script-help/28818/3 "2018-10-18T20:27:05Z")

</div>

Thanks, Jordan. I’ve already tried that, and here’s the return:

fatal: [kcrook10]: FAILED! =\> {“changed”: true, “cmd”: “powershell.exe -ExecutionPolicy Bypass -File C:\temp\command\_update.ps1 -ConsoleTitle "Dell Command | Update"”, “delta”: “0:00:00.546000”, “end”: “2018-10-18 08:24:45.319793”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2018-10-18 08:24:44.773793”, “stderr”: “At C:\temp\command\_update.ps1:232 char:8\r\n+ } else {\r\n+ ~\r\nMissing closing ‘}’ in statement block or type definition.\r\n + CategoryInfo : ParserError: (🙂 , ParentContainsErrorRecordEx \r\n ception\r\n + FullyQualifiedErrorId : MissingEndCurlyBrace\r\n \r\n”, “stderr\_lines”: [“At C:\temp\command\_update.ps1:232 char:8”, “+ } else {”, “+ ~”, “Missing closing ‘}’ in statement block or type definition.”, " + CategoryInfo : ParserError: (🙂 , ParentContainsErrorRecordEx “, " ception”, " + FullyQualifiedErrorId : MissingEndCurlyBrace", " "], “stdout”: “”, “stdout\_lines”: }

Any other ideas?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 18, 2018, 11:08pm UTC](https://forum.ansible.com/t/powershell-script-help/28818/4 "2018-10-18T23:08:00Z")

</div>

That says around line 232 of your PowerShell script is missing a brace. This is a syntax issue in your script and not an issue in Ansible.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [October 19, 2018, 3:55pm UTC](https://forum.ansible.com/t/powershell-script-help/28818/5 "2018-10-19T15:55:50Z")

</div>

Thanks, again, Jordan. Yes, when I look more closely, I saw that, and fixed it in the script. All’s well now.
