How can I query PCs with PowerShell installed?

I'd like to upgrade all non-server clients in our environment to PowerShell 4.0. It is a mix of Win7 and Win8.1 devices so I only want to target the Win7 machines that have version 2.0 or 3.0 installed. I've built a Package/Program to deploy the framework package and that is working. My next challenge is to query the correct set of machines on the network. Normally I'd create a WMI query and assign those devices to the collection the app is deployed to. In this case I can't seem to build a query that finds the machines.

Installed Executable is no good as there are only a dozen or so of the 300-400 machines that appear in that search. I haven't been able to used the Registry - Name query either to look for a specific key.

Any ideas or insight into how to do this would be appreciated. I've scoured Google and have yet to find a silver bullet.


0 Comments   [ + ] Show comments

Answers (2)

Posted by: sparky86 6 years ago
Fourth Degree Brown Belt

for SCCM i would set a condition against the application deployment to check against the following reg key as this identifies PowerShell version


there should be a string called Powershellversion

and you can set the condition to equal or less than 3.0

any machine running 4.0 would not be targeted this will allow you to deploy to a large collectionmachines but only those that have an older version would get the update package

  • Would you be setting the condition in a Task Sequence then since you are referring to the deployment? - quattro004 6 years ago
  • What I am noticing is PCs with 4.0 installed still have the key from the prior version left over so I'm not sure I will be able to get an accurate list only looking for that one key and value. - quattro004 6 years ago
Posted by: dedenker 6 years ago
3rd Degree Black Belt
Can you not better deploy the update via WSUS (SCCM or not)?
To select only workstations there are many ways: WMI and LDAP always are for sure.
In my envirorment we use a machine naming convention and we keep workstations in a separate IP range.

But a SCCM collection should already be build in.

  • I haven't come across info on successfully deploying PowerShell via WSUS. WMI is how I'd normally query machines that need the update, but I haven't been able to locate a place on our machines that consistently shows the presence of PowerShell and its version that WMI reports on. I think I may have found a way buy building it as an Application in SCCM and setting a requirement based on OS and a Detection Method that looks for a PowerShellEngine value of 4.0. If the value does not exist and it's a Win7 machine, the app installs.

    My problem now is that Software Center is sent a 3010 error code which signifies a passive reboot is required and is reporting the installation as a failure even though it was successful pending the reboot. - quattro004 6 years ago
    • Try these two:
      -> http://www.nowmicro.com/deploying-windows-management-framework-4-with-configmgr/

      -> http://www.jonathanmedd.net/2013/10/windows-management-framework-powershell-4-0-is-now-available-ensure-you-already-have-net-4-5.html - dedenker 6 years ago
      • Those are great write ups. Thank you for the link. Unfortunately, I still receive a 3010 error code and the Application shows failed in Software Center even after repairing .NET 4.5.2 which is already installed on 99% of our clients. I am deploying WMF 4.0 exactly how they are in the blog post but they don't seem to mention having the same issue I am. - quattro004 6 years ago
      • I think my detection method is what is flagging it as a Failure. The detection method is calling $PSVersionTable looking for a value of 4.0 to be true, since the PC has not rebooted and applied the updates, the version is still listed as 2.0 and considers it to be a failure. The thing is, after rebooting and applying the update, it still reports it as a failure. I need to find where Windows is holding the 4.0 files before it applies them and use one that sticks around as the Detection method. At least that is the theory as of now.. - quattro004 6 years ago
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ