简体   繁体   English

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

[英]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.

相关问题 Windows Server 2012 R2中的Virtualbox错误 - Windows Server 2012 R2 in Virtualbox error Windows Server 2012 R2上的MSSQL Server远程登录问题 - MSSQL Server Remote Login Issue on Windows Server 2012 R2 事件4625 Windows安全审核无法登录。 失败原因:用户名未知或密码错误 - Event 4625 windows security auditing failed to logon. Failure Reason:Unknown user name or bad password 脚本未从Windows Server 2012 R2上的任务计划程序运行 - Script not running from task scheduler on Windows Server 2012 R2 在 Windows Server 2012 R2 上安装 Websense 软件时出错 - Error Installing Websense Software on Windows Server 2012 R2 Windows 2012 Server R2标准应用程序上的控制台应用程序错误 - Console Application Error on Windows 2012 server R2 standard application Windows 2012 R2服务器下的imagepng - imagepng under a Windows 2012 R2 Server 还原AWS EC2 Windows Server 2012 R2管理员密码 - Restore AWS EC2 Windows Server 2012 R2 Administrator's password Microsoft Azure 订阅下的 Windows Server 2012 R2 远程桌面许可证激活 - Windows Server 2012 R2 Remote Desktop License activation under Microsoft Azure subscription 在Windows Server 2008 R2上重置密码 - Reset password on Windows Server 2008 R2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM