Trying to Retrieve Reg Value From Remote Machines RRS feed

  • Question

  • I am trying to retrieve a registry value from each computer using a for each loop and then output that value to a folder in a csv.
    That part works fine. The part I am having an issue with is having powershell connect to the remote computers. 

    This is running internal only
    I have admin rights across all workstations
    Firewalls are configured to allow all traffic to pass

    When I run this script I get this error for every workstation it tried to connect to:

    Enter-PSSession : Connecting to remote server workstationX failed with the following error message : WinRM cannot complete the operation. Verify that the 
    specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and 
    allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local 
    subnet. For more information, see the about_Remote_Troubleshooting Help topic.
    At C:\Users\Rich_Ellis\Desktop\O365\O365Channels\O365Channel.ps1:5 char:2
    + {Enter-PSSession -ComputerName $Computer
    +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (workstationX:String) [Enter-PSSession], PSRemotingTransportException
        + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
    My script is:

    $Computers = Get-Content "C:\Users\Rich_Ellis\Desktop\O365\O365Channels\computers.txt"
    foreach ($Computer in $Computers)
    {Enter-PSSession -ComputerName $Computer 
    $key = 'HKLM:\SOFTWARE\Microsoft\Office\CLickToRun\Configuration'
    (Get-ItemProperty -Path $key -Name CDNBaseUrl).CDNBaseUrl | Export-CSV -path "\\s00itstorage\OfficeChannel\$($env:COMPUTERNAME)-O365Channel03292018.csv"}

    Any help would be appreciated. TIA
    Thursday, March 29, 2018 2:46 PM


All replies

  • Please use the code pasting tool when putting code into your question :)

    Can you use Enter-PSSession on all the servers when not using this script?

    Learn PowerShell                     Script Requests

    -Remember to mark the correct response as the answer-

    Thursday, March 29, 2018 3:01 PM
  • You can delete this post. Thanks!
    • Marked as answer by Rich Ellis-MC Friday, August 24, 2018 2:19 PM
    Wednesday, May 30, 2018 6:52 PM