powershell-2.0 - 当我收到密码复杂性错误时如何使用 Chocolatey Nuget 安装 Postgres

标签 powershell-2.0 chocolatey

我正在尝试使用 Chocolatey nuget 安装 postgresql,但出现以下错误:

Write-Error : postgresql did not finish successfully. Boo to the chocolatey gods!

[ERROR] Exception calling "SetInfo" with "0" argument(s): "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.

这是因为设置的用户名是 postgres,密码是 Postgres1234,所以我想 you aren't allowed your username in your password .

有没有办法将密码作为参数传递给巧克力安装? 或者我可以在运行包时使用一些 Powershell 魔法来更改密码规则?


更新:我的pull request在 PG 8 和 9 包中更改密码已被接受,因此一旦通过 choco install

可以看到新版本的包,这个问题就会消失

最佳答案

因此,我设法使用以下方法禁用了密码复杂性要求:

#Postgres cannot install because the password contains the username so
Mkdir c:\temp -ErrorAction SilentlyContinue
secedit /export /cfg c:\temp\secpol.cfg
(gc c:\temp\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | sc C:\temp\secpol.cfg
secedit /configure /db c:\windows\security\local.sdb /cfg c:\temp\secpol.cfg /areas SECURITYPOLICY 
rm -force c:\temp\secpol.cfg -confirm:$false
#then install
cinst postgresql
cinst pgadmin3

secedit 调用是答案 found here 的修改版本.该答案不会将更改保存到此处使用 | 添加的 secpol 文件。 sc C:\temp\secpol.cfg

很明显,如果您来到此处并粘贴此代码...您应该考虑之后重新启用复杂性。

我仍然对解决这个问题的更好方法感兴趣...

关于powershell-2.0 - 当我收到密码复杂性错误时如何使用 Chocolatey Nuget 安装 Postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26715449/

相关文章:

powershell - 这是 PowerShell 类型解析机制中的边缘案例吗?

powershell - 如何获取 Powershell 脚本参数的帮助消息?

powershell - 我/我需要如何处置自定义PSObject?

.net - 为什么 powershell 有时会将 PSObject(而不是基础对象)传递给 .Net 代码?

regex - 在csv doc中使用powershell,需要迭代并插入字符

git - 如何将其他文件添加到 Chocolatey 包中?

cmd - Chocolatey Ngrok.portable 不工作

PowerShell 7 使用 Chocolatey 作为 PackageManager

powershell - Vagrant Install-ChocolateyInstallPackage : $File parameter not recognized

node.js - “node -v”在 'choco upgrade nodejs' 之后显示错误版本