Powershell get-credentials失败

时间:2015-01-02 02:31:05

标签: windows powershell credentials

PS C:\Windows\system32> $creds = Get-Credential
  

cmdlet Get-Credential命令管道位置1的供应值   以下参数:Credential

PS C:\Windows\system32> $ses = New-PSSession -ComputerName WIN-O4VC136J0E2 -Credential $creds
  

New-PSSession:[WIN-O4VC136J0E2]连接到远程服务器   WIN-O4VC136J0E2失败,并显示以下错误消息:用户   名称或密码不正确。有关更多信息,请参阅   about_Remote_Troubleshooting帮助主题。在行:1字符:8   + $ ses = New-PSSession -ComputerName WIN-O4VC136J0E2 -Credential $ creds   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~       + CategoryInfo:OpenError:(System.Manageme .... RemoteRunspace:RemoteRunspace)[New-PSSession],   PSRemotin gTransportException       + FullyQualifiedErrorId:LogonFailure,PSSessionOpenFailed

我使用的凭据与我以前手动登录的凭据相同。还有别的我做错了吗?我尝试了几种不同的方式,似乎永远无法登录。

1 个答案:

答案 0 :(得分:0)

尝试以下操作,可以很好地使用域帐户或本地帐户:

# Enter your pass and stores it securely:
$SecureString = Read-Host -AsSecureString 'Enter your password ' | ConvertFrom-SecureString | ConvertTo-SecureString
# Users you password securly
$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "MyLoCalMachine\MyUserID",$SecureString
# Sets yous credentials to be used
$RemoteConn = New-PSSession -ComputerName $ts -Credential $MySecureCreds -Authentication default