2 Best Ways to 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.
Table of Contents
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.
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
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.
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.
- CMPivot Query
- 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 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.
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.
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.
At the bottom, select the Run Details tab, and you should find the PowerShell version of every single computer.