Powershell获取凭据失败

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

cmdlet命令pipe道位置1上的Get-Credential为以下参数提供值:Credential

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

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

我使用的凭据与我手动login的凭据相同。 有什么我做错了吗? 我尝试了几种不同的方式,似乎永远不能login。

Solutions Collecting From Web of "Powershell获取凭据失败"

尝试以下方法,可以很好地与域帐户或本地帐户配合使用:

 # 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