4

Besides looking dumping $PSVersionTable and dumping the variable and env "PS-Drives", what can I do to compare PowerShell environments?

Here's the problem:

  • I have very similar machines running Microsoft Windows Server 2012
  • $PSVersionTable dumps as:

    Name                           Value
    ----                           -----
    PSVersion                      4.0
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    CLRVersion                     4.0.30319.34014
    BuildVersion                   6.3.9600.17090
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
    PSRemotingProtocolVersion      2.2
    

    on the server that works, and

    Name                           Value
    ----                           -----
    PSVersion                      4.0
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    CLRVersion                     4.0.30319.34209
    BuildVersion                   6.3.9600.16406
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
    PSRemotingProtocolVersion      2.2
    

    on the server that I'm having a problem with.

  • Not a whole not of difference in a base variable: drive.
  • Reasonable differences in env: contents
  • And they both have ExecutionPolicy set to RemoteSigned.

So the differences are in the minor version. But the first server will run the Animal classes example that comes with the PSClass deployment, and the second won't.

And I've traced it in the debugger to the second call to Attach-PSScriptMethod, whether in a debugger or not, the second server just hangs on that call.


Update: Just got a change to update my first server to Build 6.3.30319.34209, the same minor version as the second (and the same CLRVersion). Now the example breaks as well. Looks like Microsoft broke the PSClass library.

I hope not too many scripts rely on the OO model used there, because if they broke the simple example, they could as well have broken heavier code.

I still can't even get it to dump out the problem it has

5
  • This is a close one, but you will probably get better results on Stack Overflow. While Powershell is generally on-topic here, this question is particularly code-centric in a way that I think makes it appropriate for either site. – Ryan Ries Feb 24 '15 at 21:27
  • Thanks, @RyanRies. I was thinking similarly, which is why I mainly asked whether there is a script or a tool to verbosely dump the factors that play into a powershell environment. – Axeman Feb 24 '15 at 22:19
  • I'm running the latest PS 5.0 preview and observe the same behavior. In my case it's loops forever in theAttach-PSScriptMethod, where no loops exist at all. – beatcracker Feb 24 '15 at 22:42
  • @beatcracker, That makes sense, because an update to my first server did the same thing. Check my update. So the CLRVersion or the minor build version seems to have something to do with it. – Axeman Feb 24 '15 at 23:41
  • 1
    @beatcracker, it looks like in overriding the ToString method, something in PSClass's override mechanism tries to call ToString and you get a recursion issue. – Axeman Mar 17 '15 at 14:34
0

Starting Powershell version 4.0 and above you can use $PSVersionTable. Anything less than version 4.0, you would need to use Get-Host

Determine Installed Powershell Version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.