Powershell Remoting Failing After Server Restore - powershell

Our server had been set up to have Powershell Remoting enabled, so that we can remotely execute scripts from our developer machines. I should add that I am not massively fluent in Powershell and was not involved in setting this up.
However recently our server suffered a fault and subsequently had to be restored. The restoration process was supposed to restore Windows back to its last backed up state including all programs and data. However since the restore, Powershell Remoting no longer works on the server.
I receive the following error now when running Enter-PSSession ServerName.
Enter-PSSession : Connecting to remote server failed with the following error message : <f:WSManFault xmlns:f="http://s
chemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2147749890" Machine="ServerName"><f:Message></f:Message></f:WSManFaul
t> For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:16
+ enter-pssession <<<< ServerName
+ CategoryInfo : InvalidArgument: (ServerName:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Or I get the following error when running New-PSSession ServerName
[ServerName] Connecting to remote server failed with the following error message : <f:WSManFault xmlns:f="http://schemas.
microsoft.com/wbem/wsman/1/wsmanfault" Code="2147749890" Machine="ServerName"><f:Message></f:Message></f:WSManFault> For
more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
eption
+ FullyQualifiedErrorId : PSSessionOpenFailed
(I have replaced the actual server name above with ServerName for privacy purposes)
Any help is much appreciated

Based on this Microsoft Connect item, try adding-SessionOption (New-PSSessionOption -NoMachineProfile) to your Enter-PSSession command.
I have no idea why this would be needed, but it's worth a shot.

Related

Remote session terminated when running Powershell script at 'Start-Process'

I'm attempting to run a Powershell script that calls the Start-Process function in order to begin installing some monitoring software. I'm attempting to run it via a remote shell session I entered using Enter-PSSession. I've verified that the argument list and file path are correct in the line below.
Start-Process -FilePath $Installer -ArgumentList $ArgList -Wait -PassThru
When the script reaches this line however, it closes my remote session with the server I'm in and throws one of the following errors:
Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response. A provider in the host
process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException
or
Starting a command on the remote server failed with the following error message : An operation is being attempted on a session that is being closed.This can happen if the
session that is being used is also being closed by another thread. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException
I've tried doubling the max memory allocation per shell to 2Gb but that hasn't helped. Has anybody experienced an issue like this before?

Grant-CsTeamsAppPermissionPolicy not working in microsoft teams powershell

I am trying to apply permission policy to a user via powershell but it is not working
PS C:\Users\PO30261> Grant-CsTeamsAppPermissionPolicy -PolicyName "HR App Policy" -Identity d72f6b50-ac75-470a-80b8-919ab8b3232e
Get-CsOnlineSession : Connecting to remote server api.interfaces.records.teams.microsoft.com failed with the following error message : The WinRM client cannot process the request. Basic
authentication is currently disabled in the client configuration. Change the client configuration and try the request again. For more information, see the about_Remote_Troubleshooting Help
topic.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.3.1\net472\SfBORemotePowershellModule.psm1:63 char:22
$remoteSession = & (Get-CsOnlineSessionCommand)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Get-CsOnlineSession], PSRemotingTransportException
FullyQualifiedErrorId : PSRemotingTransportException,Microsoft.Teams.ConfigApi.Cmdlets.GetCsOnlineSession
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.3.1\net472\SfBORemotePowershellModule.psm1:19581 char:38
... -Session (Get-PSImplicitRemotingSession -CommandName 'Grant-CsTeam ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidData: (:) [Invoke-Command], ParentContainsErrorRecordException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Error shows that issue is not related to apply policy. Issue is with connecting to server "Basic authentication is currently disabled in the client configuration" so update module and try again. Update-Module MicrosoftTeams
Seems like a problem with powerShell version. Look at this discussion where community are following this issue, including me:
https://techcommunity.microsoft.com/t5/teams-developer/authenticating-with-an-access-token-connect-microsoftteams/m-p/2233794

Enter-PSSession not working, Firewall port 5985 is open

Error:
Enter-PSSession : Connecting to remote server sadcm0000081 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 line:1 char:1
+ Enter-PSSession -ComputerName sadcm0000081
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (sadcm0000081:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Test-WSN Output:
Test-Wsman : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859046" Machine="SADCM0000078.adc
.corpintra.net"><f:Message>WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer i
s accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. B
y default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. </f:Messa
ge></f:WSManFault>
At line:1 char:1
+ Test-Wsman -ComputerName sadcm0000081
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (sadcm0000081:String) [Test-WSMan], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand
Try first to running powershell Enable-PSRemoting with an administrator console.
After that look after the Windows Firewall rules of remote administration.

Powershell PSSessionStateBroken error

I use the following powershell command to RDP to a server and start a service. It was working fine until last week before we cut over the server to a different data center.
Invoke-Command -ComputerName itbldw13 {Start-Service -Name bamboo-remote-agent}
The error that i get after the cut over is
Connecting to remote server itbldw13 failed with the following error message : The client cannot connect to the destination specified in the request.
+ CategoryInfo : OpenError: (itbldw13:String) [], PSRemotingTrans portException
+ FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
Could someone help me fix this error please

Remote command failure even after unencrypted traffic is true

I am trying to open remote PSSession from one PC to another. Both PCs are in the LAN and reachable, but whenever I try to enter PSSession the following error occurs:
Enter-PSSession : Connecting to remote server pc2 failed with the
following error message : The WinRM client cannot process the request.
Unencrypted traffic is currently disabled in the client configuration.
Change the client configuration and try the request again. For more
information, see the about_Remote_Troubleshooting Help topic. At
line:1 char:1
+ Enter-PSSession -ComputerName pc2 -Authentication Basic -Credential admin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (pc2:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
I have set AllowUnencrypted to true in both
WSMan::localhost\Client
and
WSMan::localhost\Service
location on the remote PC, but still getting the same error. Are there other settings I need to update?