[英]Logon failure: unknown username or bad password error on Windows Server 2012 R2 for Remote PS script execution
I am trying to run a powershell script from a TeamCity Windows Slave to another server for deploying my application.我正在尝试从 TeamCity Windows 从站运行 powershell 脚本到另一台服务器以部署我的应用程序。
This is BuildConfig:这是构建配置:
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"
I am getting the following error.我收到以下错误。
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.
I have used the correct User name and password only.我只使用了正确的用户名和密码。 I have also checked the Local User security policies.
我还检查了本地用户安全策略。 Am I missing something?
我错过了什么吗?
Is it just a paste error that missed the $ from username?它只是一个粘贴错误,错过了用户名中的 $ 吗? Does the user name and password work fine outside the script?
用户名和密码在脚本之外可以正常工作吗? Are the variables being substituted in properly.
变量是否被正确替换。 Do the logs show?
日志显示吗? I've never used that construct to make a pscredential before.
我以前从未使用过该构造来制作凭据。 Is this one mentioned here not working.
这里提到的这个不起作用。
https://pscustomobject.github.io/powershell/howto/PowerShell-Create-Credential-Object/ https://pscustomobject.github.io/powershell/howto/PowerShell-Create-Credential-Object/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.