Monday, April 2, 2012

Revisiting PowerShell Remoting

In a previous post, I mentioned configuring PowerShell Remoting so that I could start doing nifty PowerShell scripting stuffs without having to RDP into the server to do it. You know, The UNIX Way™. As I mentioned in a subsequent post, my remoting had suddenly and mysteriously broken such that while I could run around the filesystem all day long, executing a SharePoint cmdlet on the remote system would turn my session Broken.

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.

Well, that's unhelpful, since I thought I had fixed this in the past. I spent an hour or so wrangling with it, disabling and re-enabling WSManCredSSP, but what finally tipped me off to the underlying cause of the problem was running winrm s winrm/config/client. I don't have the string output from the command handy since I have since closed that PS window, but in essence it told me that I was getting an underlying firewall exception because one of my NICs was set to Public Network (the VirtualBox Host-Only Network adapter). What? I thought we fixed that!

Opening up the Network and Sharing Center told me that, lo and behold, I was back on a Public network! It didn't take long for me to figure out what had happened - an upgraded version of VirtualBox likely removed and replaced the virtual NIC, and so it was set back to a Public Network. Bollocks!

Well, I fixed that problem, but I was still experiencing the same error trying to run SharePoint cmdlets (this was the point where I restarted the PowerShell session to clear my head), and then it occurred to me that I might need to restart WinRM in order to effect this change (other articles say to disable/enable the NIC, but I did not find this necessary). So, I restarted the WinRM service, and then I ran Get-SPServiceApplication about 10 times just to make sure I wasn't deceiving myself in that the commands were working...

Well, with that finally fixed, now I can set about configuring my remote profiles so that I will never, ever need to retype Add-PSSnapIn Microsoft.SharePoint.PowerShell...

No comments:

Post a Comment