Which is best method to authenticate the Remote machine

Welcome Forums General PowerShell Q&A Which is best method to authenticate the Remote machine

Viewing 3 reply threads
  • Author
    Posts
    • #236227
      Participant
      Topics: 2
      Replies: 8
      Points: 24
      Rank: Member

      As of now I  tried using Wsman commands and it succeed in most cases.

      Here is the sample code for that:

      $Password = ConvertTo-SecureString $password -AsPlainText -Force
          $Username = $username    
          $Cred = New-Object System.Management.Automation.PSCredential ($Username, $Password)
          $Session = New-PSSession -ComputerName $Target.ip -Credential $Cred
          if(-not($Session)){
              Remove-PSSession $Session
              throw "Access Denied. Invalid credentials."
          }
          Remove-PSSession $Session

      Can any one suggest any better approach to authenticate the remote machine with credentials. Above cases has a loop-hole that it will freeze when connection is lost(no error comes up just hangs)

    • #236389
      Participant
      Topics: 0
      Replies: 37
      Points: 371
      Helping Hand
      Rank: Contributor

      Hello Dave1185,
      What is your scenario?
      Are you trying to accomplish 1 to 1 remoting or 1 to many?

      I would strongly suggest to read Secrets of PowerShell Remoting. It will answer most of your remoting questions and explain best practices.

      Hope that helps.

      • #238676
        Participant
        Topics: 2
        Replies: 8
        Points: 24
        Rank: Member

        Hi AndySvints,
        My scenario is 1 to 1 remoting. And I have read the book suggested by you. I need to say it cleared many concepts. But still, I cannot accomplish

        • to identify if the remote machine is reachable or not.
        • if there is connection failure during the execution of scripts the output of PowerShell goes in an infinite loop.
    • #236425
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Dave,
      when you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.

      https://social.technet.microsoft.com/Forums/en-US/bc1749b3-3325-48b4-a1f9-16dcd71f6bc5/which-is-best-method-to-authenticate-the-remote-machine?forum=winserverpowershell

      Thanks

    • #236449
      Participant
      Topics: 2
      Replies: 8
      Points: 24
      Rank: Member

      Hello Dave1185,

      What is your scenario?

      Are you trying to accomplish 1 to 1 remoting or 1 to many?

      I would strongly suggest to read Secrets of PowerShell Remoting. It will answer most of your remoting questions and explain best practices.

      Hope that helps.

      Hey, Thanks for your reply and apologies for reposting on other platforms Olaf.
      My scenario is 1 to 1 remoting. Can u help me more on this,

      Thanks in advance

      • This reply was modified 3 months ago by Dave1185.
Viewing 3 reply threads
  • You must be logged in to reply to this topic.