Cannot create remote powershell session after Enable-PSRemoting

前端 未结 7 817
别跟我提以往
别跟我提以往 2021-01-30 23:45

I can not remote into any machine to save my life! I have tried everything I can find. If anyone could troubleshoot or guide me, I\'d appreciate it as this would be a great tool

7条回答
  •  无人及你
    2021-01-30 23:49

    This is how I do it. I use this on my scripts.

    # This is only done once
    Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File
    c:\Windows\temp\securepass.txt
    
    # Setup credentials
    $SecureString = Get-Content c:\Windows\temp\securepass.txt | ConvertTo-SecureString
    $mycredentials = New-Object -TypeName System.Management.Automation.PSCredential
        -ArgumentList "yourDomain\userID",$SecureString
    
    # Open remote session:
    $MyRSession = New-PSSession -ComputerName Computer1 -Credential $mycredentials
        -Authentication default
    
    # Use remote session:
    Enter-PSSession $MyRSession
    

提交回复
热议问题