Invoke-Coomand Domain Joined Computer to Work Group Server

Welcome Forums General PowerShell Q&A Invoke-Coomand Domain Joined Computer to Work Group Server

Viewing 6 reply threads
  • Author
    Posts
    • #232642
      Participant
      Topics: 35
      Replies: 110
      Points: 576
      Rank: Major Contributor

      PowerShell 5.1
      Windows 10 Pro Domain Joined Powershell 5.1
      Windows 2019 Server Work Group Powershell 5.1

      tying to run

      invoke-command -computername server32 -scriptblock {get-service}

      PS C:\util> Invoke-Command -ComputerName server032 -ScriptBlock {get-service}
      [server032] Connecting to remote server tgcs032 failed with the following error message : WinRM cannot process the
      request. The following error occurred while using Kerberos authentication: Cannot find the computer tgcs032. Verify
      that the computer exists on the network and that the name provided is spelled correctly. For more information, see the
      about_Remote_Troubleshooting Help topic.
      + CategoryInfo : OpenError: (tgcs032:String) [], PSRemotingTransportException
      + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken
      PS C:\util>

      Then I tried this

      PS C:\util> set-item -Path WSMAN:\\localhost\client\TrusteedHosts -Value ‘SERVER32’ -force
      set-item : This command cannot be used because path does not exist.Check the path existence and run your command.
      At line:1 char:1
      + set-item -Path WSMAN:\\localhost\client\TrusteedHosts -Value ‘SERVER032 …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (:) [Set-Item], InvalidOperationException
      + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetItemCommand

      Any ideas on how I can run this from my Domain computer to a work group server?

      Thank you

      Tom

    • #232666
      Participant
      Topics: 3
      Replies: 431
      Points: 1,533
      Helping Hand
      Rank: Community Hero

      You could explore and confirm paths

      cd wsman:
      dir
      cd .\localhost\client
      Set-Item .\TrustedHosts -Value ‘SERVER32’
      

      Tab complete is your friend. Then you don’t have to worry about possible spelling mistakes such as

      TrusteedHosts

      set-item -Path WSMAN:\\localhost\client\TrusteedHosts -Value ‘SERVER032 …

      Now if you’re still having issues, make sure you’re running as admin. Hope this helps

    • #232699
      Moderator
      Topics: 4
      Replies: 231
      Points: 1,260
      Helping Hand
      Rank: Community Hero

      PS C:\util> set-item -Path WSMAN:\\localhost\client\TrusteedHosts -Value ‘SERVER32’ -force set-item : This command cannot be used because path does not exist.Check the path existence and run your command.

      Run PowerShell as an Administrator and try the above command, it will work.

      And on the remote computer, run the command below…

      Enable-PSRemoting -Force

      … on the source computer test your connection using the command below

      Test-WSMan -ComputerName <remotecomputer>

      Thank you.

    • #232765
      Participant
      Topics: 35
      Replies: 110
      Points: 576
      Rank: Major Contributor

      Doug,

      Fat Fingers LOL

      PS C:\util> cd wsman:
      PS WSMan:\> cd .\localhost\client
      PS WSMan:\localhost\Client> set-item .\TrustedHosts -Value ‘SERVER032’

      WinRM Security Configuration.
      This command modifies the TrustedHosts list for the WinRM client. The computers in the TrustedHosts list might not be
      authenticated. The client might send credential information to these computers. Are you sure that you want to modify
      this list?
      [Y] Yes [N] No Suspend [?] Help (default is “Y”): y

      PS WSMan:\localhost\Client> Invoke-Command -ComputerName SERVER032 -ScriptBlock {get-service}
      [SERVER032] Connecting to remote server SERVER032 failed with the following error message : WinRM cannot process the
      request. The following error occurred while using Kerberos authentication: Cannot find the computer SERVER032. Verify
      that the computer exists on the network and that the name provided is spelled correctly. For more information, see the
      about_Remote_Troubleshooting Help topic.
      + CategoryInfo : OpenError: (tgcs032:String) [], PSRemotingTransportException
      + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken

      PS WSMan:\localhost\Client> ls

      WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

      Type Name SourceOfValue Value
      —- —- ————- —–
      System.String NetworkDelayms 5000
      System.String URLPrefix wsman
      System.String AllowUnencrypted false
      Container Auth
      Container DefaultPorts
      System.String TrustedHosts SERVER032

      KIRAN
      From SERVER032 Which is my Work Group Server

      PS C:\util> enable-psremoting -force
      PS C:\util> test-wsman -ComputerName DESKTOP1

      wsmid : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
      ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
      ProductVendor : Microsoft Corporation
      ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0

      DESKTOP1 is my Windows 10 Pro Domain Joined. PS I can invoke-command to all my Desktops and Servers that are domain joined just not this one Work Group server

      I always run Powershell as administrator

      Thank you

    • #232777
      Moderator
      Topics: 4
      Replies: 231
      Points: 1,260
      Helping Hand
      Rank: Community Hero

      @Tom – Since the remote server is not domain joined, you need to authenticate the server, so use -Credential parameter and pass the credentials with the Invoke-Command.

      And I hope there is no firewall block. And by any chance did you try using IP address??

      Thank you.

       

    • #232783
      Participant
      Topics: 35
      Replies: 110
      Points: 576
      Rank: Major Contributor

      Kiran,

      I only use the Windows Firewall and WinRM Ports are open.

      I did try by ip address and that failed also.

      Adding the creds Test worked

      PS WSMan:\localhost\Client> Invoke-Command -ComputerName SERVER032 -credential administrator -ScriptBlock {get-service}
      Status Name DisplayName PSComputerName
      —— —- ———– ————–
      Stopped AJRouter AllJoyn Router Service SERVER032
      Stopped ALG Application Layer Gateway Service SERVER032
      Running AppHostSvc Application Host Helper Service SERVER032
      Stopped AppIDSvc Application Identity SERVER032
      Stopped Appinfo Application Information SERVER032
      Stopped AppMgmt Application Management SERVER032
      Stopped AppReadiness App Readiness SERVER032
      Stopped AppVClient Microsoft App-V Client SERVER032
      Stopped AppXSvc AppX Deployment Service (AppXSVC) SERVER032
      Stopped aspnet_state ASP.NET State Service SERVER032
      Stopped AudioEndpointBu… Windows Audio Endpoint Builder SERVER032
      Stopped Audiosrv Windows Audio SERVER032
      Stopped AxInstSV ActiveX Installer (AxInstSV) SERVER032
      Running BFE Base Filtering Engine SERVER032
      Stopped BITS Background Intelligent Transfer Ser… SERVER032
      Running BrokerInfrastru… Background Tasks Infrastructure Ser… SERVER032
      Stopped BTAGService Bluetooth Audio Gateway Service SERVER032
      Running BthAvctpSvc AVCTP service SERVER032
      Stopped bthserv Bluetooth Support Service SERVER032
      Stopped camsvc Capability Access Manager Service SERVER032
      Stopped CaptureService_… CaptureService_bac71 SERVER032

      Adding the creds did the trick

      Thank you

    • #232789
      Moderator
      Topics: 4
      Replies: 231
      Points: 1,260
      Helping Hand
      Rank: Community Hero

      That’s great! I was asking you to ensure that there is no firewall block.

      And you must provide the credentials when it is outside of your domain network whether it is by name or ip.

      Thank you.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.