# How to export flows of a nodered server from remote server with powershell?

**URL:** <https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579>\
**Category:** General\
**Tags:** importexport, flows\
**Created:** [13 January 2025 13:52 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579 "2025-01-13T13:52:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dargento](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@dargento](https://discourse.nodered.org/u/dargento)\
**Post date:** [13 January 2025 13:52 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/1 "2025-01-13T13:52:52Z")

</div>

Hello, We have several nodered servers in our company and I want export the flows from each server periodically for some evaluation. When the server has no authentication (just on test server) I can directly get flows with [https://mynoderedserver:1880/flows](https://mynoderedserver:1880/flows). But when the servers have authentication I get "unauthorized". Normaly I can login to the servers and export the flows manually. But I want to be able to do that with a powershell script. I have also tried some scripts with credentials but each time I get the flows.json file just with the comment "unauthorized".

When I enter NodeRed webpage with my credentials I see that as user I am defined as admin. Why can I not download the flows.json file? How should I proceed?

My Code is:

```auto
# Define the Node-RED server URL
$nodeRedUrl = "https://myserver:1881"

$apiEndpoint = "/flows"

# Define the credentials
$username = "myusername"
$password = "mypassword"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $securePassword)

# Make an HTTP GET request with credentials to retrieve the flows
$response = Invoke-WebRequest -Uri ($nodeRedServerUrl + $apiEndpoint) -Method Get -Credential $credential

# Save the response content to a JSON file in C:\temp
$response.Content | Set-Content -Path "C:\temp\flows.json"

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 January 2025 14:07 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/2 "2025-01-13T14:07:34Z")

</div>

Welcome to the forum @dargento

If you want the full flow set then you can just pick up the flows file rather than exporting.

---

<div class="post-metadata">

**Author:** ![dargento](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@dargento](https://discourse.nodered.org/u/dargento)\
**Post date:** [14 January 2025 05:45 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/3 "2025-01-14T05:45:28Z")

</div>

Hello Colin thank you for answer

You are absolutely right, transfering the file would be the easiest way, but in our company we have firewall zone concept, and ports for file transfer are extremely restricted. There is a lot of procedure to get approvement for ports like 445 or ftp.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [14 January 2025 06:16 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/4 "2025-01-14T06:16:31Z")

</div>

> [@dargento](#):
>
> `$securePassword = ConvertTo-SecureString $password -AsPlainText -Force`

Basic auth is a base64 string. The `ConvertTo-SecureString` creates some microsoft kind of string (not sure what this is, but it is not a base64 string of the user+pass).

a google search points to something like:

```auto
$pair = "$($user):$($pass)"
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Pair))
$headers = @{ Authorization = "Basic $encodedCredentials" }

Invoke-WebRequest -Uri $url -Method Get -Headers $headers

```

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [14 January 2025 06:49 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/5 "2025-01-14T06:49:05Z")

</div>

If the following works passing thru your firewalls, well...I suppose

You could try to use the admin API

Myself, I did setup a remote Node-RED and I communicate successfully with that instance via a public MQTT cloud service (HiveMQ). From a local NodeRED instance I can check if the remote is online or not, ask for the complete flow as well as separate tabs, update existing or add newtabs and some other specific tasks like getting complete chart data. All communication goes thru the MQTT cloud service and I have not opened any ports in the firewalls

> [@Experimenting with the Admin API](https://discourse.nodered.org/t/experimenting-with-the-admin-api/93641/3):
>
> I continued my stumbling experimenting further, now with nodes kindly shared by @gregorius In my nearby, local RPi, I have a flow that can send a request to a remote RPi to get the complete flow returned. Communication between the both is via a public MQTT cloud service (HiveMQ) The returned flow is saved to disk. Then being imported for some editing, then exported to a another file, finally sent to the remote, again via MQTT My local RPi When the flow is arrived at the remote site…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 April 2025 06:49 UTC](https://discourse.nodered.org/t/how-to-export-flows-of-a-nodered-server-from-remote-server-with-powershell/94579/6 "2025-04-14T06:49:51Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
