2 Best Ways to Find PowerShell Version using SCCM

Prajwal Desai
Posted by Prajwal Desai
Find PowerShell Version using SCCM

In this article, I will show you how to find PowerShell version using SCCM. We will use CMPivot query and Scripts feature to get PowerShell version in SCCM.

So, what is PowerShell ?. PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework.

PowerShell is commonly used for automating the management of systems. The PowerShell runs on Windows, Linux, and macOS.

PowerShell is installed by default in all Windows versions starting from Windows 7 SP1 and Windows Server 2008 R2 SP1. The Windows 10 default PowerShell version is 5.1.

Learning PowerShell adds more value to your work because you can automate complex tasks using PowerShell. It’s a big topic and I would recommend to start learning PowerShell from Microsoft documentation.

How can I find PowerShell version on a computer?

There are multiple ways to check PowerShell version on a computer. On any computer, you can easily find the PowerShell version using the $PSversiontable command. The PSVersion indicates the PowerShell version, which is 5.1.17763.1971 in this case.

find the PowerShell version using the $PSversiontable command
Find the PowerShell version using the PSversiontable command

If you want to find the build number along with revision, you can run the command $PSVersionTable.PSVersion. This command reveals the following details about PowerShell.

  • Major version
  • Minor Version
  • Build number
  • Revision
Find the PowerShell version using the PSversiontable command
Find the PowerShell version using the PSversiontable command

An alternate method to find the PowerShell version is by running a command host. Launch the PowerShell and run the command, host and that should show the PowerShell version.

Find the PowerShell version using host command
Find the PowerShell version using host command

Most of you who have been working with PowerShell know about finding the version. However, the above methods involve running the commands on individual computers.

When you have many computers in your setup, running commands on each version will take time. So in this case, we can use SCCM to find the PowerShell version on computers.

We will use two methods to find PowerShell version using SCCM.

  1. CMPivot Query
  2. SCCM Scripts feature

In addition to above two methods, many of you will argue that there are other methods to find PowerShell version using SCCM. Yes, I don’t deny that, but I am going to show you the easiest methods to find PowerShell version using SCCM.

Find PowerShell Version using SCCM CMPivot Query

CMPivot is a useful utility in SCCM that can simply your tasks. When you run a CMPivot query, it immediately runs a query on all currently connected devices in the SCCM device collection and returns the results.

In this blog, I have covered several examples of how CMPivot queries can be used to achieve your tasks. You can take a look at all the SCCM CMPivot query examples that I have published so far.

Let’s look at the steps to find PowerShell version using SCCM CMPivot query. Launch the SCCM console and navigate to Assets and Compliance > Overview > Device Collections. Right-click a device collection and select Start CMPivot.

Run the below command in the CMPivot query window to get the PowerShell version on computers. The below command finds the PowerShell using the registry.

Registry('hklm:\SOFTWARE\Microsoft\Powershell\3\PowershellEngine') | where Property == 'PowerShellVersion'
Find PowerShell Version using SCCM CMPivot Query
Find PowerShell Version using SCCM CMPivot Query

Find PowerShell Version using SCCM Scripts

You can create and run PowerShell scripts from the Configuration Manager console. Configuration Manager has an integrated ability to run PowerShell scripts and this is a very useful feature.

To run the scripts using ConfigMgr, the clients must be running the client from the 1706 release, or later and the PowerShell version 3.0 or later.

If you are new to scripts, I would recommend spending some time reading about how you can create and deploy scripts in ConfigMgr.

Alright, so let’s learn how to find PowerShell version using SCCM scripts. First go to Software Library\Overview\Scripts and create a New Script. On the Script Details window, enter the command $psversiontable and click Next.

Find PowerShell Version using SCCM Scripts
Find PowerShell Version using SCCM Scripts

Complete the remaining steps and close the create script wizard. You should see the newly created script under Scripts.

Before you can run the script, right-click the Find PowerShell version script and click Approve. You must approve a script because unless you approve it, you won’t be able to run it.

When you add a new script in SCCM, you may notice the Approve/Deny option is greyed out or disabled. To resolve the issue, you must turn off Script Authors require additional script approver option. For more information on this, refer fix SCCM Script approve deny Option is disabled.

Once you have approved the script, you can now run it on a device collection. Right-click a device collection and select Run Script. You must select the script that you wish to run. Select the Find PowerShell version script and click Next.

Find PowerShell Version using SCCM Scripts
Find PowerShell Version using SCCM Scripts

Click Next on Summary page and wait while the script runs on the computers that are part of device collection. On the Script Status Monitoring window, we see that script status is completed, meaning the script execution is successful.

By default, the script output is displayed in a Bar Chart. The $PSversion is included in the results, and it includes the Major version and Minor version.

Find PowerShell Version using SCCM Scripts
Find PowerShell Version using SCCM Scripts

At the bottom, select the Run Details tab, and you should find the PowerShell version of every single computer.

Find PowerShell Version using SCCM Scripts
Find PowerShell Version using SCCM Scripts
Share This Article
Prajwal Desai
Posted by Prajwal Desai
Follow:
Prajwal Desai is a Microsoft MVP in Intune and SCCM. He writes articles on SCCM, Intune, Windows 365, Windows Server, Windows 11, WordPress and other topics, with the goal of providing people with useful information.