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


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



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

最佳答案

尝试以下操作,无论是域帐户还是本地帐户都可以很好地工作:

# 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

关于windows - Powershell 获取凭据失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27736735/

10-10 16:47