Hi Jon,

thank's a lot for your repsonse.
The script is found and executed on the remote  (The file is uploaded 
properly to the ftp server). But somehow this special powershell script 
seems to return something that indicates winrm that an error occurred. 

I already found a workaround for my problem by using the basic dos command 
ftp.exe instead of the System.Net.FtpWebRequest in my script.

I was  wondering what information indicates winrm that an error occurred 
and if I could somehow try to retrieve the full message that is displayed 
in err = "" 
(<10.0.2.176> WINRM RESULT <Response code 0, out "UploadFile.ps1 is ca", 
err "#< CLIXML <Objs Ver">)

The only difference I can see between an successful task and the one marked 
as error is that the value of "err" is not empty.

I was already trying to retrieve this message on the windows remote by 
calling my powershell script from another powershell script by $errror[0] 
was empty.

Thorsten


Am Mittwoch, 7. Oktober 2015 15:53:50 UTC+2 schrieb Thorsten Klaus:
>
> Hi everyone,
>
> I am already running multiple tasks using raw on my windows remote. The 
> patch that is mentioned in previouse posts (KB2842230) is already installed.
>
> When I am running my playbook, I am getting the following error:
>
> Code hier eingeben...<10.0.2.176> WINRM RESULT <Response code 0, out 
> "UploadFile.ps1 
> is ca", err "#< CLIXML <Objs Ver">
> fatal: [10.0.2.176] => Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
> line 586, in _executor
>     exec_rc = self._executor_internal(host, new_stdin)
>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
> line 789, in _executor_internal
>     return self._executor_internal_inner(host, self.module_name, self.
> module_args, inject, port, complex_args=complex_args)
>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
> line 1036, in _executor_internal_inner
>     result = handler.run(conn, tmp, module_name, module_args, inject, 
> complex_args)
>   File 
> "/usr/lib/python2.7/site-packages/ansible/runner/action_plugins/raw.py", 
> line 47, in run
>     become=self.runner.become)
>   File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", 
> line 1174, in _low_level_exec_command
>     in_data=in_data)
>   File 
> "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/winrm.py"
> , line 165, in exec_command
>     return (result.status_code, '', result.std_out.encode('utf-8'), result
> .std_err.encode('utf-8'))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 240: 
> ordinal not in range(128)
>
> Can anyone tell me how I can get the full error mentioned in the WINRM 
> RESULT ("err "#< CLIXML <Objs Ver").
>
> Here is my current setup:
>
> The playbook:
> - name: Upload a file to the ftp-Server.
>   hosts: builder
>   
>   tasks:
>     - name: upload 
>       raw: d:\PowershellScripts\UploadFile.ps1
>
> My powershell script:
>  #we specify the directory where all files that we want to upload  
>
> $LocalFile="C:\foo.txt"    
>
> $RemoteFile = "ftp://192.168.1.50/foo.txt"; 
>
> $Username = "user" 
>
> $Password = "pass"  
>
> # Create FTP Rquest Object
>
> $FTPRequest = [System.Net.FtpWebRequest]::Create("$RemoteFile")
>
> $FTPRequest = [System.Net.FtpWebRequest]$FTPRequest
>
> $FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
>
> $FTPRequest.Credentials = new-object System.Net.NetworkCredential(
> $Username, $Password)
>
> $FTPRequest.UseBinary = $true
>
> $FTPRequest.UsePassive = $true
>
> # Read the File for Upload
>
> $FileContent = gc -en byte $LocalFile
>
> $FTPRequest.ContentLength = $FileContent.Length
>
> # Get Stream Request by bytes
>
> $Run = $FTPRequest.GetRequestStream()
>
> $Run.Write($FileContent, 0, $FileContent.Length)
>
> # Cleanup
>
> $Run.Close()
>
> $Run.Dispose()
>
>
> Kind regards
> Thorsten
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f986d105-404a-4ad6-b48a-a4bf7b84a085%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to