# Win\_ping Module | failed to run exec\_wrapper | URGENT

**URL:** <https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 24, 2020, 9:16am UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313 "2020-02-24T09:16:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush\_Bansal](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@Piyush\_Bansal](https://forum.ansible.com/u/Piyush_Bansal)\
**Post date:** [February 24, 2020, 9:16am UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/1 "2020-02-24T09:16:15Z")

</div>

Hello,

I am running win\_ping for windows 2008R2 64bit server from ansible 2.8.2 & python version = 2.7.5. Below are connection parameters:  
winrm  
ssl  
5986  
ignore certificates  
Admin user  
Credentials are working fine and no issues.

While running this task I am getting following error. Never have faced such error before.  
Please be so kind to suggest on this.

TASK [win\_ping] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win\_ping.ps1  
Pipelining is enabled.  
\<a.b.c.d\> ESTABLISH WINRM CONNECTION FOR USER: adm on PORT 5986 TO a.b.c.d  
EXEC (via pipeline wrapper)  
The full traceback is:  
Failed to compile C# code:  
error CS0013: Unexpected error writing metadata to file ‘c:\Users\Adm\AppData\Local\Temp\xyz.dll’ – ‘��"’  
At line:279 char:13

- throw [InvalidOperationException]$msg
- 

```auto

```

- CategoryInfo : OperationStopped: (🙂 , InvalidOperationException
- FullyQualifiedErrorId : Failed to compile C# code:  
error CS0013: Unexpected error writing metadata to file ‘c:\Users\Adm\AppData\Local\Temp\xyz.dll’ – ‘��"’

ScriptStackTrace:  
at Add-CSharpType, : line 279  
at , : line 19  
at , : line 137  
at , : line 7

fatal: [a.b.c.d]: FAILED! =\> changed=false  
msg: |-  
internal error: failed to run exec\_wrapper action module\_powershell\_wrapper: Failed to compile C# code:  
error CS0013: Unexpected error writing metadata to file ‘c:\Users\Adm\AppData\Local\Temp\xyz.dll’ – ‘"’

Let me know if you need further details…!!  
I have changed the dll files,IP address, user etc details for obvious security reasons.

Thanks,  
Piyush

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 24, 2020, 9:14pm UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/2 "2020-02-24T21:14:14Z")

</div>

I have not seen this error before, but what permissions are on  
c:\Users\Adm\AppData\Local\Temp\ directory?

Do you get any more information if you run ansible with -vvvvvv option?

---

<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:** [February 24, 2020, 10:06pm UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/3 "2020-02-24T22:06:12Z")

</div>

We use C# code in our code for a lot of things, in this case it’s the Ansible wrapper we use to abstract the communication to and from the controller. Part of that process is to compile the C# code to a dll and load that in PowerShell. This all happens in the background and is part of PowerShell, similar to how the Add-Type cmdlet works.

If it’s failing to write to a file in the temp directory then it could be an issue with;

- Not having permissions to the dir
- Antivirus blocking the process  
I don’t think it’s the permissions issue as that’s the temp dir for the current user but it’s probably still a good idea to check. As for the anti-virus, it could be seeing a process writing a dll as something suspicious and just block it from doing so. Unfortunately this is how Ansible compiles the C# code for use in it’s modules and we can’t really do too much about that. I would check to see if there are any AV logs to see if it logged a reason why it blocked access.

---

<div class="post-metadata">

**Author:** ![Piyush\_Bansal](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@Piyush\_Bansal](https://forum.ansible.com/u/Piyush_Bansal)\
**Post date:** [February 26, 2020, 12:30pm UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/4 "2020-02-26T12:30:51Z")

</div>

Hello Jordan and Hawkesworth,

Many Thanks for your email…!!

I disabled all services of Anti-Virus software on the server and tried win\_ping but still the same issue.  
Tried with unrestricted, remotesigned and bypass execution policy but still win\_ping does not work.

Local user account which I am using to connect to windows server definitely has full access so, full permissions every where on this server.

Please note that it is not giving any permission not found on any file rather it says file not found…!!!

Below is the traceback with -vvvvv verbosity:

TASK [win\_ping] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win\_ping.ps1  
Pipelining is enabled.  
\<a.b.c.d\> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO a.b.c.d  
\<a.b.c.d\> WINRM CONNECT: transport=ssl endpoint=[https://a.b.c.d:5986/wsman](https://a.b.c.d:5986/wsman)  
\<a.b.c.d\> WINRM OPEN SHELL: 6557236D-D283-4BAC-AFF8-E5FFC26B3265  
EXEC (via pipeline wrapper)  
\<a.b.c.d\> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-EncodedCommand’, u’UAAGUAZABDAG8AbQBtAGEAbgBkACAASgBnAEIAagBBAEcAZwBBAFkAdwBCAHcAQQBDADQAQQBZAHcAQgB2AEEAAQgAwAEEARwBVAE\*\*\*\*\*\ ***ALPHANUMERICCHARSREMOVEDFORBEVERTY** 8EASwBBAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBCAGIAQQBEAEEAQQBYAFEAQQBwAEEAQQBvAEEASgBnAEEAawBBAEcAVQBBAGUAQQBCAGwAQQBHAE0AQQBYAHcAQgAzAEEASABJAEEAWQBRAEIAdwBBAEgAQQBBAFoAUQBCAHkAQQBBAD0APQA=‘]  
\<a.b.c.d\> WINRM RESULT u’\<Response code 1, out "{“exception”:“Failed”, err “”\>’  
\<a.b.c.d\> WINRM STDOUT {“exception”:“Failed to compile C# code: \r\nerror CS0010: Unexpected fatal error – \u0027n\u0027\r\nAt line:279 char:13\r\n+ throw [InvalidOperationException]$msg\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \r\n + CategoryInfo : OperationStopped: (🙂 , InvalidOperationException\r\n + FullyQualifiedErrorId : Failed to compile C# code: \r\nerror CS0010: Unexpected fatal error – \u0027n\u0027\r\n\r\nScriptStackTrace:\r\nat Add-CSharpType, \u003cNo file\u003e: line 279\r\nat \u003cScriptBlock\u003e, \u003cNo file\u003e: line 19\r\nat \u003cScriptBlock\u003e\u003cEnd\u003e, \u003cNo file\u003e: line 137\r\nat \u003cScriptBlock\u003e, \u003cNo file\u003e: line 7\r\n”,“msg”:“internal error: failed to run exec\_wrapper action module\_powershell\_wrapper: Failed to compile C# code: \r\nerror CS0010: Unexpected fatal error – \u0027n\u0027”,“failed”:true}

\<a.b.c.d\> WINRM STDERR  
\<a.b.c.d\> WINRM CLOSE SHELL: 6558656D-D283-4BAC-AJJ8-E5FFC26B3612  
The full traceback is:  
Failed to compile C# code:  
error CS0010: Unexpected fatal error – ‘n’  
At line:279 char:13

- throw [InvalidOperationException]$msg
- 

```auto

```

- CategoryInfo : OperationStopped: (🙂 , InvalidOperationException
- FullyQualifiedErrorId : Failed to compile C# code:  
error CS0010: Unexpected fatal error – ‘n’

ScriptStackTrace:  
at Add-CSharpType, : line 279  
at , : line 19  
at , : line 137  
at , : line 7

fatal: [a.b.c.d]: FAILED! =\> changed=false  
msg: |-  
internal error: failed to run exec\_wrapper action module\_powershell\_wrapper: Failed to compile C# code:  
error CS0010: Unexpected fatal error – ‘n’

Thanks,  
Piyush

---

<div class="post-metadata">

**Author:** ![Piyush\_Bansal](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@Piyush\_Bansal](https://forum.ansible.com/u/Piyush_Bansal)\
**Post date:** [February 26, 2020, 12:53pm UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/5 "2020-02-26T12:53:23Z")

</div>

Hello,

I allowed unencrypted on winrm client and winrm service with unrestricted execution-policy.  
Below is the detailed traceback for win\_ping:

TASK [win\_ping] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win\_ping.ps1  
Pipelining is enabled.  
\<a.b.c.d\> ESTABLISH WINRM CONNECTION FOR USER: ADM on PORT 5986 TO a.b.c.d  
\<a.b.c.d\> WINRM CONNECT: transport=ssl endpoint=[https://a.b.c.d:5986/wsman](https://a.b.c.d:5986/wsman)  
\<a.b.c.d\> WINRM OPEN SHELL: 79601CF5-4113-4573-9E10-BC60C19BCD21  
EXEC (via pipeline wrapper)  
\<a.b.c.d\> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-EncodedCommand’, u’UABvAHcAZQByAFMAaABlAGwAbAAgACsadsfasdfasdfasAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARQBuAGMAbwBkAGUAZABD **ALPHANUMERICCHARREMOVEDFORBEVERTY** \*\*\*\*\*\*\*\*\*\*\*\*QQBLAEEAQwBRAEEAWgBRAEIANABBAEcAVQBBAFkAdwBCAGYAQQBIAGMAQQBjAGcAQgBoAEEASABBAEEAYwBBAEIAbABBAEgASQBBAEkAQQBBADkAQQBDAEEAQQBXAHcAQgBUAEEARwBNAEEAYwBnAEIAcABBAEgAQQBBAGQAQQBCAEMAQQBHAHcAQQBiAHcAQgBqAEEARwBzAEEAWABRAEEANgBBAEQAbwBBAFEAdwBCAHkAQQBHAFUAQQBZAFEAQgAwAEEARwBVAEEASwBBAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBCAGIAQQBEAEEAQQBYAFEAQQBwAEEAQQBvAEEASgBnAEEAawBBAEcAVQBBAGUAQQBCAGwAQQBHAE0AQQBYAHcAQgAzAEEASABJAEEAWQBRAEIAdwBBAEgAQQBBAFoAUQBCAHkAQQBBAD0APQA=‘]  
\<a.b.c.d\> WINRM RESULT u’\<Response code 1, out "{“exception”:“Except”, err “”\>’  
\<a.b.c.d\> WINRM STDOUT {“exception”:“Exception calling "CompileAssemblyFromDom" with "2" argument(s): "Could not find file \u0027C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll\u0027."\r\nAt line:19 char:5\r\n+ Add-CSharpType -References $csharp\_utils -TempPath $new\_tmp -IncludeDebugInf …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \r\n + CategoryInfo : NotSpecified: (🙂 [Add-CSharpType], MethodInvocationException\r\n + FullyQualifiedErrorId : FileNotFoundException,Add-CSharpType\r\n\r\nScriptStackTrace:\r\nat Add-CSharpType, \u003cNo file\u003e: line 273\r\nat \u003cScriptBlock\u003e, \u003cNo file\u003e: line 19\r\nat \u003cScriptBlock\u003e\u003cEnd\u003e, \u003cNo file\u003e: line 137\r\nat \u003cScriptBlock\u003e, \u003cNo file\u003e: line 7\r\n\r\nSystem.Management.Automation.MethodInvocationException: Exception calling "CompileAssemblyFromDom" with "2" argument(s): "Could not find file \u0027C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll\u0027." —\u003e System.IO.FileNotFoundException: Could not find file \u0027C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll\u0027.\r\n at [System.IO](http://System.IO).\_\_Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY\_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)\r\n at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String fileNames)\r\n at Microsoft.CSharp.CSharpCodeGenerator.FromDomBatch(CompilerParameters options, CodeCompileUnit ea)\r\n at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit ea)\r\n at CallSite.Target(Closure , CallSite , Object , Object , Object )\r\n — End of inner exception stack trace —\r\n at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)\r\n at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)\r\n at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)\r\n at System.Management.Automation.CommandProcessorBase.Complete()”,“msg”:“internal error: failed to run exec\_wrapper action module\_powershell\_wrapper: Exception calling "CompileAssemblyFromDom" with "2" argument(s): "Could not find file \u0027C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll\u0027."”,“failed”:true}

\<a.b.c.d\> WINRM STDERR  
\<a.b.c.d\> WINRM CLOSE SHELL: 79601CF5-4113-4573-9E10-BC60C19BCD21  
The full traceback is:  
Exception calling “CompileAssemblyFromDom” with “2” argument(s): “Could not find file ‘C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll’.”  
At line:19 char:5

- Add-CSharpType -References $csharp\_utils -TempPath $new\_tmp -IncludeDebugInf …
- 

```auto

```

- CategoryInfo : NotSpecified: (🙂 [Add-CSharpType], MethodInvocationException
- FullyQualifiedErrorId : FileNotFoundException,Add-CSharpType

ScriptStackTrace:  
at Add-CSharpType, : line 273  
at , : line 19  
at , : line 137  
at , : line 7

System.Management.Automation.MethodInvocationException: Exception calling “CompileAssemblyFromDom” with “2” argument(s): “Could not find file ‘C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll’.” —\> System.IO.FileNotFoundException: Could not find file ‘C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll’.  
at [System.IO](http://System.IO).\_\_Error.WinIOError(Int32 errorCode, String maybeFullPath)  
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY\_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)  
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)  
at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)  
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String fileNames)  
at Microsoft.CSharp.CSharpCodeGenerator.FromDomBatch(CompilerParameters options, CodeCompileUnit ea)  
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit ea)  
at CallSite.Target(Closure , CallSite , Object , Object , Object )  
— End of inner exception stack trace —  
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)  
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)  
at System.Management.Automation.CommandProcessorBase.Complete()  
fatal: [a.b.c.d]: FAILED! =\> changed=false  
msg: ‘internal error: failed to run exec\_wrapper action module\_powershell\_wrapper: Exception calling “CompileAssemblyFromDom” with “2” argument(s): “Could not find file ‘‘C:\Users\ADM\AppData\Local\Temp\nzq3veem.dll’’.”’

---

<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:** [February 26, 2020, 7:32pm UTC](https://forum.ansible.com/t/win-ping-module-failed-to-run-exec-wrapper-urgent/32313/6 "2020-02-26T19:32:51Z")

</div>

I completely spaces that you are running against Server 2008 R2. There’s a bug with PowerShell v3 and remoting around out of memory issues which commonly appears like stuff you are seeing here. Make sure you have met the pre-reqs and either

- Update PowerShell to v5 preferably
- Install the Windows hotfix for v3 [1]  
The hotfix is hard to get but that link should have enough details to get you started. I would highly recommend you upgrade to PowerShell v5 anyway as that contains some nice logging features you can take advantage of.

[1] - [https://docs.ansible.com/ansible/latest/user\_guide/windows\_setup.html#winrm-memory-hotfix](https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#winrm-memory-hotfix)

Thanks

Jordan
