If you’ve been working with Windows Server Containers in Windows Server 2016 (WS2016) Technical Preview 3 (TPv3) then you’ve probably experienced something like this:
- You create a new container
- Then start the container
- And try to create a PowerShell session into the container using Enter-PSSession
And then there’s lots of red on the screen:
enter-pssession : The term ‘Measure-Object’ is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
At line:1 char:1
+ enter-pssession -ContainerId $container.ContainerId
+ CategoryInfo : ObjectNotFound: (Measure-Object:String) [Enter-PSSession], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Strangely, I have not been able to recreate this with Invoke-Command, so it appears to be unique to how Enter-PSSession sets up session in the container.
So how do you solve the issue? It’s simple – you rushed from starting your container to trying to log into it. Wait a few seconds and then try again.
One thought on “Windows Server Containers – “Enter-PSSession : The term ‘Measure-Object’ Is Not Recognized””
I have a very similar issue, I cannot Enter-PSSession to a machine in the domain that I have been able to Enter-PSSession to before, I can run Invoke-Command against it all day with no problems.
Both machines are Windows 10 Enterprise, Powershell 5.0.10240.16384.
I do have a 2016 TP3 Hyper-V Core install on my network, and I believe the problem started after I added this machine. I am still running test, but if anyone has any suggestions on how to resolve or fix it, that would be great.