# The configuration password cannot be read

**URL:** <https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001>\
**Category:** Help and Support\
**Created:** [November 10, 2022, 12:41pm UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001 "2022-11-10T12:41:05Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 10, 2022, 12:41pm UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/1 "2022-11-10T12:41:05Z")

</div>

AFTER I UPGRADED POWERSHELL TO V7.3, PROMPT:Failed to load config file "C:\Users\User\.config\rclone\rclone.conf": password-command returned empty string，Previously it was possible to pass RCLONE\_PASSWORD\_COMMAND，  
Is there anyone who can help me, thank you

---

<div class="post-metadata">

**Author:** ![albertony](https://forum.rclone.org/user_avatar/forum.rclone.org/albertony/32/8586_2.png) [@albertony](https://forum.rclone.org/u/albertony)\
**Post date:** [November 10, 2022, 1:19pm UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/2 "2022-11-10T13:19:00Z")

</div>

What is your RCLONE\_PASSWORD\_COMMAND set to then?

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 11, 2022, 5:47am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/3 "2022-11-11T05:47:38Z")

</div>

Variable name: RCLONE\_PASSWORD\_COMMAND, variable value: powershell D:\rcpw\rcpw.ps1，In the rcpw.ps1 file, **Read-Host -Prompt 'Enter rclone configuration password' -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath D:\rcpw\rcpw.txt** ，This configuration worked fine in versions prior to PowerShell 7.3, and problems occurred after upgrading to V7.3

---

<div class="post-metadata">

**Author:** ![albertony](https://forum.rclone.org/user_avatar/forum.rclone.org/albertony/32/8586_2.png) [@albertony](https://forum.rclone.org/u/albertony)\
**Post date:** [November 11, 2022, 6:38am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/4 "2022-11-11T06:38:54Z")

</div>

That command you posted only **writes** to a file, `... | Out-File -FilePath D:\rcpw\rcpw.txt`, and would not work regardless of PowerShell version. I assume you missed some of the contant of the D:\rcpw\rcpw.ps1 file?

Looks like you took inspiration from this thread:

> [@How to use RCLONE\_PASSWORD\_COMMAND with Windows Powershell for config password](https://forum.rclone.org/t/how-to-use-rclone-password-command-with-windows-powershell-for-config-password/15950):
>
> Rclone release 1.51 includes support for a new config --password-command, documented at: [https://rclone.org/docs/#configuration-encryption](https://rclone.org/docs/#configuration-encryption) This article demonstrates how to use the Windows Powershell SecureString type and PSCredential to store your configuration file password securely in a file. Generate your secure password to a disk file (for the purprose of this example, U:\rcpw.txt): Read-Host -Prompt 'Enter rclone configuration password' -AsSecureString | ConvertFrom-SecureString | Out-…

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 11, 2022, 7:37am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/5 "2022-11-11T07:37:16Z")

</div>

> [@albertony](#):
>
> I assume you missed some of the contant of the D:\rcpw\rcpw.ps1 file?

... or copied rcpw.txt from another pc or user.

The encrypted password stored in rcpw.txt can only be successfully decrypted by the Windows user and pc used to encrypt it.

If you move to another Windows user or pc then you will have to create a new rcpw.txt file by following the instructions from the beginning. I suggest you rename the old file to something like rcpw.txt.bak first.

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 13, 2022, 1:19am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/6 "2022-11-13T01:19:47Z")

</div>

Thank you for the explanation, but my usage environment has not changed, just powershell upgraded to V7.3, I rolled powershell back to V7.2, and then it works normally, so I thought it was a problem with the powershell version.

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 13, 2022, 5:44pm UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/7 "2022-11-13T17:44:27Z")

</div>

I just tested my password command and worked fine in PowerShell 7.3 (installed using winget), so I don't think your issue is (directly) related to PowerShell 7.3

Do you see your password if executing the below command in PS 7.2 and 7.3?

```
(New-Object -TypeName PSCredential -ArgumentList @( 'user', ((Get-Content -Path D:\rcpw\rcpw.txt) | ConvertTo-SecureString))).GetNetworkCredential().Password

```

What is the output from this command:

```
cat D:\rcpw\rcpw.ps1

```

Please mark the output as "Preformatted text", you can find it in the forum editor menu

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 14, 2022, 6:21am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/8 "2022-11-14T06:21:36Z")

</div>

Thank you very much, but I found strange issues, as follows：  
1.Run PowerShell  
2.Run 'rclone --password-command "powershell D:\rcpw\rcpw.ps1" lsd b2:'  
output：Failed to load config file "C:\Users\User\.config\rclone\rclone.conf": password-command returned empty string  
3.Then run： **powershell**  
4.Then run it again： rclone --password-command "powershell D:\rcpw\rcpw.ps1" lsd b2:  
5.Right now：PS C:\Windows\System32\> rclone --password-command "powershell D:\rcpw\rcpw.ps1" lsd b2:  
-1 2022-11-14 14:04:55 -1 my-bak  
now OK  
**must first run :powershell and the password command will run correctly** This is confusing，And causes the script that is scheduled to run to not run correctly

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 14, 2022, 6:43am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/9 "2022-11-14T06:43:27Z")

</div>

OK, let's take it step by step, first I need to better understand your situation.

Do you see your password if executing the below command?

```auto
(New-Object -TypeName PSCredential -ArgumentList @( 'user', ((Get-Content -Path D:\rcpw\rcpw.txt) | ConvertTo-SecureString))).GetNetworkCredential().Password

```

What is the output from this command:

```auto
cat D:\rcpw\rcpw.ps1

```

Please mark the output as "Preformatted text", you can find it in the forum editor menu

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 14, 2022, 10:49am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/10 "2022-11-14T10:49:13Z")

</div>

well,yes,I can see the password when this command is executed，and cat D:\rcpw\rcpw.ps1 output:

```auto
 cat D:\rcpw\rcpw.ps1
(New-Object -TypeName PSCredential -ArgumentList @( 'user', ((Get-Content -Path D:\rcpw\rcpw.txt) | ConvertTo-SecureString))).GetNetworkCredential().Password
PS D:\>

```

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 14, 2022, 11:41am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/11 "2022-11-14T11:41:15Z")

</div>

Perfect, now try if this shows your password:

```
pwsh D:\rcpw\rcpw.ps1

```

If it does, then try this

```
rclone --password-command "pwsh D:\rcpw\rcpw.ps1" lsd b2:

```

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 16, 2022, 6:09am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/12 "2022-11-16T06:09:10Z")

</div>

That's great，It can be executed successfully

```auto
 rclone --password-command "pwsh D:\rcpw\rcpw.ps1" lsd b2:
          -1 2022-11-16 14:07:34 -1 my-bak

```

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 16, 2022, 7:00am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/13 "2022-11-16T07:00:18Z")

</div>

Happy to hear!

I hope it also solved your issue with the scheduled script, otherwise please share the (relevant part of the) script and the error you see.

@albertony I tried without success to find a solution that would work in both Windows PowerShell (5.1) and PowerShell 7, do you have any ideas?

---

<div class="post-metadata">

**Author:** ![albertony](https://forum.rclone.org/user_avatar/forum.rclone.org/albertony/32/8586_2.png) [@albertony](https://forum.rclone.org/u/albertony)\
**Post date:** [November 16, 2022, 7:24am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/14 "2022-11-16T07:24:39Z")

</div>

> [@Ole](#):
>
> @albertony I tried without success to find a solution that would work in both Windows PowerShell (5.1) and PowerShell 7, do you have any ideas?

What is the situation, exactly? Is it: The original method from that old thread still works, as is, but not in PowerShell 7 if you use --password-command `"powershell ..."`, you have to change it to `"pwsh ..."`?

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [November 16, 2022, 8:23am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/15 "2022-11-16T08:23:34Z")

</div>

The issue is that this command doesn't work in PowerShell 7 (pwsh):

```
.\rclone.exe config show --password-command "powershell ./configpw.ps1"
2022/11/16 08:54:53 Failed to load config file "...": password-command returned empty string

```

I would expect it to execute configpw.ps1 using my Windows PowerShell (5.1), but it obviously doesn't work as expected. Executing just "powershell ./configpw.ps1" in the PowerShell 7 prompt works fine, but seems to use PowerShell 7. If I type powershell in the Start Menu then I get the Windows PowerShell 5.1...

My question is: How can I write the above command generically to make it execute correctly in Task Scheduler, CMD, Windows PowerShell (5.1) and PowerShell 7 (if installed)?

---

<div class="post-metadata">

**Author:** ![albertony](https://forum.rclone.org/user_avatar/forum.rclone.org/albertony/32/8586_2.png) [@albertony](https://forum.rclone.org/u/albertony)\
**Post date:** [November 16, 2022, 10:55am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/16 "2022-11-16T10:55:07Z")

</div>

Ok, thanks for the details. I reproduced it myself now. When using `powershell` in password command from a `pwsh` shell, and adding `*> out.txt` to the end of the password-command I see in the produced out.txt file that it errors out with:

> ConvertTo-SecureString : The 'ConvertTo-SecureString' command was found in the module 'Microsoft.PowerShell.Security',  
> but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.

The problem seems to be that when running from pwsh (PowerShell 7) it prepends PS7 installation's module path into `$Env:PSModulePath`, and this gets inherited by rclone, and then by the powershell command it executes as password command. Now that powershell (Windows PowerShell 5.1) command finds the Microsoft.PowerShell.Security module for PowerShell 7 instead of the Windows PowerShell 5.1 one, and are not able to use it.

To work around this, one possibility is to, before starting powershell in the password command, clear any PSModulePath variable (which should be set if and only if inherited from a powershell/pwsh "parent" shell rclone is running from). This will ensure that when powershell is run it sets its own proper default PSModulePath value.

```auto
.\rclone.exe config show --password-command "cmd /c SET PSModulePath=&powershell ./configpw.ps1"

```

Thats a quick and dirty fix, off the top of my head. Maybe we can come with up with a better..?

> [@Ole](#):
>
> My question is: How can I write the above command generically to make it execute correctly in Task Scheduler, CMD, Windows PowerShell (5.1) and PowerShell 7 (if installed)?

So yes, good question, what is the good, general solution for this... 🤔

---

<div class="post-metadata">

**Author:** ![albertony](https://forum.rclone.org/user_avatar/forum.rclone.org/albertony/32/8586_2.png) [@albertony](https://forum.rclone.org/u/albertony)\
**Post date:** [November 16, 2022, 12:40pm UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/17 "2022-11-16T12:40:58Z")

</div>

Another alternative is to keep the existing password command, e.g.

```auto
.\rclone.exe config show --password-command "powershell ./configpw.ps1"

```

But modify the script (here: `configpw.ps1`), and add a statement to the top that ensures PSModulePath is correct in any case. E.g.:

```auto
$Env:PSModulePath = [System.Environment]::GetEnvironmentVariable("PSModulePath","Machine")

```

Still just a _workaround_, though. It may or may not be better than the previous one..

---

<div class="post-metadata">

**Author:** ![jak01201](https://forum.rclone.org/user_avatar/forum.rclone.org/jak01201/32/13460_2.png) [@jak01201](https://forum.rclone.org/u/jak01201)\
**Post date:** [November 17, 2022, 5:56am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/18 "2022-11-17T05:56:27Z")

</div>

Since I'm only using V7, the problem seems to be solved, thanks for your patience and help.

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [December 17, 2022, 5:56am UTC](https://forum.rclone.org/t/the-configuration-password-cannot-be-read/34001/19 "2022-12-17T05:56:49Z")

</div>

Closed on December 17, 2022, 5:56am UTC

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