PowerShell - 使用本地管理员凭据连接到服务器

时间:2021-05-28 06:54:56

标签: powershell

我想通过 PowerShell 连接到远程服务器,我需要使用本地管理员帐户。

如果我使用域帐户,则一切正常。但问题是我需要连接到另一个不受信任的域。

$username = 'DOMAIN\USER'; $password = 'pasword';
$secpw = ConvertTo-SecureString $password -AsPlainText -Force
$cred  = New-Object Management.Automation.PSCredential ($username, $secpw)
Invoke-Command -ComputerName DAVOSTEST2.TDA01.POJ -ScriptBlock { HOSTNAME } -credential $cred;

davostest2

如果我使用本地管理员帐户,则不起作用。

$username = 'AdmPS'; $password = 'password';
$secpw = ConvertTo-SecureString $password -AsPlainText -Force
$cred  = New-Object Management.Automation.PSCredential ($username, $secpw)
Invoke-Command -ComputerName DAVOSTEST2.TDA01.POJ -ScriptBlock { HOSTNAME } -credential $cred;

[DAVOSTEST2.TDA01.POJ] Connecting to remote server DAVOSTEST2.TDA01.POJ failed with the following error message : The user name or p
assword is incorrect. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (DAVOSTEST2.TDA01.POJ:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken

$username = 'DAVOSTEST2\AdmPS'; $password = 'password';
$secpw = ConvertTo-SecureString $password -AsPlainText -Force
$cred  = New-Object Management.Automation.PSCredential ($username, $secpw)
Invoke-Command -ComputerName DAVOSTEST2.TDA01.POJ -ScriptBlock { HOSTNAME } -credential $cred;

[DAVOSTEST2.TDA01.POJ] Connecting to remote server DAVOSTEST2.TDA01.POJ failed with the following error message : WinRM cannot proce
ss the request. The following error with errorcode 0x80090311 occurred while using Kerberos authentication: There are currently no l
ogon servers available to service the logon request.  
 Possible causes are:
  -The user name or password specified are invalid.

问题出在哪里?

0 个答案:

没有答案