Powershell 获取凭据失败

Powershell get-credentials fails

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

cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: Credential

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

New-PSSession : [WIN-O4VC136J0E2] Connecting to remote server WIN-O4VC136J0E2 failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:8 + $ses = New-PSSession -ComputerName WIN-O4VC136J0E2 -Credential $creds + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin gTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionOpenFailed

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

尝试以下方法,使用域帐户或本地帐户都能很好地工作:

# 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