# \[ProcessLibrary\] Log result from PowerShell command

**URL:** <https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352>\
**Category:** Libraries\
**Created:** [23 February 2023 11:06 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352 "2023-02-23T11:06:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brahim1991](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Brahim1991](https://forum.robotframework.org/u/Brahim1991)\
**Post date:** [23 February 2023 11:06 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/1 "2023-02-23T11:06:42Z")

</div>

Hello everyone,

I use a PowerShell command in RobotFramework, and I want to send the result of my command in a file.

I added " \> myfile.txt" in the end of my command, there is no problem when I do it manually, my file is created with the good result inside.

But when I run this same command in RobotFramework, my file is created but empty

Can anyone help me please?

Thank you!

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [23 February 2023 13:13 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/2 "2023-02-23T13:13:15Z")

</div>

Hi @Brahim1991,

Are you are using [Run Process](http://robotframework.org/robotframework/latest/libraries/Process.html#Run%20Process)? If so, you probably want to not use `> myfile.txt` but rather `stdout=myfile.txt` (see the [Process configuration](http://robotframework.org/robotframework/latest/libraries/Process.html#Process%20configuration) link in [Run Process](http://robotframework.org/robotframework/latest/libraries/Process.html#Run%20Process) help). if you don’t actually need the result in a file, just need to test the output you might want to look at `${result.stdout}` also mentioned in the documentation.

Otherwise can you show us what your trying to do so we can guide you better.

Dave.

---

<div class="post-metadata">

**Author:** ![Brahim1991](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Brahim1991](https://forum.robotframework.org/u/Brahim1991)\
**Post date:** [23 February 2023 13:27 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/3 "2023-02-23T13:27:37Z")

</div>

☹ quote=“damies13, post:2, topic:5352”]  
stdout  
[/quote]

Hi @damies13 , and than you for your response.

Yes I use Run Process as this :

Run Process Powershell.exe -Command [convert]::ToBase64String((Get-Content -path “C:\Users\BB\PycharmProjects\pythonProject\resources\xml\String\_Linearise\_01.txt” -Encoding byte)) stdout=encoded.txt #shell=true

I also tried without commenting shell=true, in the two cases my file is created bt empty ☹

---

<div class="post-metadata">

**Author:** ![Brahim1991](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Brahim1991](https://forum.robotframework.org/u/Brahim1991)\
**Post date:** [23 February 2023 15:34 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/4 "2023-02-23T15:34:39Z")

</div>

I found a solution : I created a .ps1 file with my command inside, and I call it from RobotFramework as :

run process Powershell.exe ${CURDIR}${/}b64.ps1

Thank you for your help 🙂

---

<div class="post-metadata">

**Author:** ![Surekha-tfs](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/surekha-tfs/32/3628_2.png) [@Surekha-tfs](https://forum.robotframework.org/u/Surekha-tfs)\
**Post date:** [6 May 2024 03:00 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/5 "2024-05-06T03:00:39Z")

</div>

Hi All,  
I created one powershell script for uninstalling postgresql  
and trying to run from robotframe work file .The testcase is passed but postqresql is not uninstalled.

\*\*\* Settings \*\*\*  
Library Process  
\*\*\* Variables \*\*\*  
${uninstallerPath} C:\Users\Ps\Downloads\powershell\uninstall-postgresql.ps1  
\*\*\* Test Cases \*\*\*  
Uninstall PostgreSQL  
${result}= Run Process powershell.exe -File ${uninstallerPath} shell=$True  
Any idea on how tonrun powershell scrit from robot framework

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [6 May 2024 05:09 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/6 "2024-05-06T05:09:31Z")

</div>

Hi Surekha,

Did you esacape the `\` as `\\`? ( [Escaping](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-258))

Dave.

---

<div class="post-metadata">

**Author:** ![Surekha-tfs](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/surekha-tfs/32/3628_2.png) [@Surekha-tfs](https://forum.robotframework.org/u/Surekha-tfs)\
**Post date:** [6 May 2024 05:57 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/7 "2024-05-06T05:57:17Z")

</div>

Hi @damies13  
sorry i i used \ only  
\*\*\* Settings \*\*\*  
Library Process  
\*\*\* Variables \*\*\*  
${uninstallerPath} C:\Users\Ps\Downloads\powershell\uninstall-postgresql.ps1  
\*\*\* Test Cases \*\*\*  
Uninstall PostgreSQL  
${result}= Run Process powershell.exe -File ${script\_path} shell=$True

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [6 May 2024 08:21 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/8 "2024-05-06T08:21:34Z")

</div>

Hi Surekha,

In robot framework (and in most programming languages you need to escape the `\` character, it’s because a reserved character. The link I gave you is where it tells you that in the documentation.

Dave.

---

<div class="post-metadata">

**Author:** ![Surekha-tfs](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/surekha-tfs/32/3628_2.png) [@Surekha-tfs](https://forum.robotframework.org/u/Surekha-tfs)\
**Post date:** [10 May 2024 15:23 UTC](https://forum.robotframework.org/t/processlibrary-log-result-from-powershell-command/5352/9 "2024-05-10T15:23:59Z")

</div>

Hi @damies13  
I tried with double backslashes .Its typo mistake  
In my Pc running PowerShell scripts restricted.  
i changed that now its working
