繁体   English   中英

登录失败:Windows Server 2012 R2 上用于远程 PS 脚本执行的未知用户名或密码错误

[英]Logon failure: unknown username or bad password error on Windows Server 2012 R2 for Remote PS script execution

我正在尝试从 TeamCity Windows 从站运行 powershell 脚本到另一台服务器以部署我的应用程序。

这是构建配置:

username = "<username>"
$password = "<password>"
$secstr = New-Object -TypeName System.Security.SecureString; 
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr;
Invoke-Command -ComputerName "<computer_name>" -Credential $cred -FilePath "deploy.ps1"

我收到以下错误。

following error message : Logon failure: unknown user name or bad password. 
[13:57:52]  [Step 1/1] For more information, see the about_Remote_Troubleshooting Help topic.

我只使用了正确的用户名和密码。 我还检查了本地用户安全策略。 我错过了什么吗?

它只是一个粘贴错误,错过了用户名中的 $ 吗? 用户名和密码在脚本之外可以正常工作吗? 变量是否被正确替换。 日志显示吗? 我以前从未使用过该构造来制作凭据。 这里提到的这个不起作用。

https://pscustomobject.github.io/powershell/howto/PowerShell-Create-Credential-Object/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM