簡體   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