Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Connecting to remote server failed

$
0
0

Hi,

I have 6 scripts out of which one script execute with the following error, If i am getting the below error for this script, i should get it for all the script? What i Have learnt sofar, remote connecting failed error is because Winrm is not set up properly. But how come i am able to run other scripts?

 Try
    {
	   Invoke-Command -ComputerName $Server -ErrorAction Stop -ScriptBlock {
	   [string]$RegPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
	   [string]$RegValue = "EnableLUA"
	   $OpenRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Server)
	   $SubKey = $OpenRegistry.OpenSubKey($RegPath,$false)
	   $UAC = ($Subkey.GetValue($RegValue) -eq 1)
	   if ($UAC -eq 1 )
	   {
		  return ("UAC is enabled")		  
	   }
	   else
	   {
		  return ("UAC is disabled")	
	   }
    }
   }
    Catch 
	{
		return ($_.Exception.Message)  
	}
}

ERROR:-Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remo


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>