Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 351 Vote(s) - 3.4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confusing Powershell behavior

#1
Am a bit confused w/ remote executing a powershell command. I have a test server (Win 2k8-R2-SP1) called ServerA, which has powershell remoting enabled correctly. From my dev machine (Win 2k8-R2-SP1), am able to remote execure powershell commands correctly.
But, when I try to execute the same command from a different server called ServerB (Win 2k8-R2), I get the following error

`[ServerA] 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_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionStateBroken
`

All three machines are in the same domain. My confusion is that from my dev machine, I am perfectly able to connect to ServerA and execute the command.

Will the fact that ServerB does not have SP1, make a difference? Please advise. I am using the same domain account which has admin rights on all 3 servers.

And the command that I am trying is
`Invoke-Command -ComputerName ServerA -ScriptBlock {Get-UICulture}`.

Please help.

Thanks
Reply

#2
Run `winrm quickconfig` or ` Enable-PSRemoting -force` from ServerB.

Verify service is running with `get-service winrm`

[To see links please register here]


Also, run this from your local dev box:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
Reply

#3
I've had this same problem as well, on a machine that was working for remote powershell in the past. In my case the solution was to clear the Security Log. It was full, and I believe this was preventing powershell from making a proper secure connection.
Reply

#4
The following fixed my problem:

You either have to empty your iplisten list which can be checked using the following CMD command:

netsh http show iplist

or to add the loop back address to it if there is any other addresses:

netsh http add iplisten 127.0.0.1
Reply

#5
To save having to enable WinRM on every single server you manage, you can run this batch script:

Requirements:

- A text file with all the servers you wish to enable WinRM on
- PSExec in your Windows\System32 directory, downloaded from:

[To see links please register here]

- Powershell on the server you're connecting to

Usage: EnablePSRemoting.bat PCs.txt

@echo off
for /f %%f in (%1) do (
psexec.exe \\%%f -accepteula -h -d -s powershell.exe "enable-psremoting -force"
echo Enabled on %%f
)
Reply

#6
I have been looking for the answer for days and I found the issue;

It seems that the IIS 7 .NET Extensibility component was not installed causing this issue. We have a 2012 R2 Exchange 2010 server;

[To see links please register here]


I installed it by entering this in powershell;

See here the prerequisites for Exchange 2010.

[To see links please register here]


This Exchange server of ours has only the mailbox role, the other is still CAS and HUB transport;

So we need this command;

Add-WindowsFeature NET-Framework-Features,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Basic-Auth,Web-Lgcy-Mgmt-Console,Web-Metabase,Web-Net-Ext,Web-Server,Web-Windows-Auth -Restart


The part of Web-Net-Ext installed the IIS 7.NET Extensibility component.
No need to restart.

Just my 2 cents, maybe this helps someone else :-)
Reply

#7
I was having this same issue and resolved in the following way. Running

winrm quickconfig

returned the below error.

winrm : WSManFault
At line:1 char:1
+ winrm quickconfig
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (WSManFault:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Message
ProviderFault
WSManFault
Message = WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.
Error number: -2144108183 0x80338169
WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.

In my case, this was a virtual NIC for a hypervisor service I was running on my machine. Once I changed this to Private, winrm quickconfig ran without error. I still had issues connecting to some machines and getting the same failure as described in this thread. To resolve, I checked for and started the winrm service where it was stopped.

get-service -ComputerName computer -Name winrm

Status Name DisplayName
------ ---- -----------
Stopped winrm Windows Remote Management (WS-Manag...



get-service -ComputerName computer -Name winrm | Start-Service
Reply

#8
In my case, WinRM was **not** configured correctly. This is what I used to enable it remotely:

$x=Get-WmiObject -ComputerName "<computer name>" -Namespace "root\cimv2" -Class "Win32_Process" -List
$x.Create('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command {Enable-PSRemoting}"',$null,$null)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through