Technical – PowerShell / Microsoft .Net CLR Version

Technical – PowerShell / Microsoft .Net CLR Version

 

Background

A week or so ago, I tried running Microsoft SharePoint 2010 Administration Toolkit on an MS Windows box.

I ran into problems due to the SharePoint diagnostic tool not being compatible with the default PowerShell/.Net Framework combo on the Windows 2012 box.

Here is the first in a series of post on the school yard beating I took.

Introduction

In this post, I will limit our discussion to ensuring that our pre-requisites are installed and functioning.   Those pre-requisites are Microsoft PowerShell and Microsoft .Net v4. and v3.5.

Confirm installation of Microsoft .Net 3.5 & PowerShell 2.0 Engine

Courtesy of (http://technet.microsoft.com/en-us/library/hh849675.aspx), here are the install\confirmation steps:

Add Microsoft .Net 3.5

  • In Server Manager, from the manage menu, select the Add Roles and Features
  • Select the Server and click on the “Add Roles and Features” option
  • On the Installation Type page, select “Role-based or feature-based” installation
  • On the features page, expand the .Net 3.5 Framework features and select .Net Framework 3.5 (includes .Net 2.0 and 3.0)

WindowsDotNetFrameworkInstallation

To add the Windows PowerShell 2.0 Engine feature

  • In Server Manager, from the manage menu, select the Add Roles and Features
  • Select the Server and click on the “Add Roles and Features” option
  • On the Installation Type page, select “Role-based or feature-based” installation
  • On the features page, expand the “PowerShell (installed)” option and select the “Windows PowerShell 2.0 Engine” option

WindowsPowerShellInstallation

Get OS/CLR Version

To get OS/CLR Version within PowerShell, we can try the following commands:

  • [System.Environment]::OSVersion.Version
  • (Get-WmiObject -class Win32_OperatingSystem).Caption
  • $PSVersionTable

The most important for our current discussion is the $PSVersionTable command:


$PSVersionTable

Output:

On MS Windows 2008/R2 box, you will see:

versionInfoOS2008R2Standard

On MS Windows 2012, you will see:

window2012-default

On MS Windows 2012, if your application demands and requires Version 2, then based on the example documented below, add “-version 2” as a command line argument when starting Poweshell

Syntax Screen:

PowerShellCommandLineVariable

So we issue :


powershell -version 2

And, replay the Version and CLR Info we previously mentioned:

PowershellCLR2onMSWindows2012

Summary:

Here is a quick run-down of OS, PowerShell Version’s support along with Microsoft.Net CLR support and thereof backward compatibility.

OS PSVersion CLRVersion CLR Version Backward
Win2008-R2  2.0 2.0.50727.572 {1.0,2.0}
Win2012  3.0 4.0.30319.18051 {1.0,2.0,3.0}
Win2012 (-v2)  2.0 2.0.50727.6407 {1.0, 2.0}

System Info Tools

As said, PowerShell loads Microsoft.Net dll depending on the OS Version and/or command line parameters.

One popular tool for reviewing system information and activities are of-course SysInternals set of tools.

Windows 2012

In the screen-shot above, we initiated PowerShell on an MS Windows 2012, and did not pass in any command-line parameter:

SysInternals-PowerShell-Windows2012-Image

Here are the Microsoft .Net Dlls loaded:

SysInternals-PowerShell-Windows2012-DotNetAssemblies

From the screen-shot above, we can see the following:

  • on the left panel, we can see that we are on CLR v4.0
  • On the right panel, we have the listing on .Net 4.0 native assemblies loaded

Windows 2012 (passed in -version 2.0)

The screen below indicates what things look like when we pass in the “-version 2.0” option; please pay attention to the “command line” section.

SysInternals-PowerShell-Windows2012-with-v2-Image

And, here is CLR Version & DLL Listings

SysInternals-PowerShell-Windows2012-with-v2-DotNetAssemblies

So we are able to confirm that when we pass in the “-version 2.0” option, we get PowerShell to go back in time.

Conclusion

In follow-up posts, I will discuss the actual problems I ran into and the series of fruitless steps I tried to correct it.

References

References – Determine Version#

References – PowerShell 2.0 Engine

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s