Detect Powershell Exist


I am looking for a simple query that can detect if a powershell module exists or not. If not, then install the module on the target windows endpoint.

Any help will be gladly appreciated.

I would imagine a relevancy clause based on the install location. My relavancy clause and location is:
(not exists file “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”)

I am very new to this as well I’ve only created a couple of tasks that work in the PowerShell language on specific models. Working on a fixlet, and converting all my old batch files to PowerShell/BigFix language.


The path presented is where windows installs powershell. But there is another folder in c:\program files where powershell stores modules. Attempting to run a query for this location is tricky. The powershell modules and file extensions are not necessarily straightforward.

Oh my bad, I didn’t think of modules again I’m new to PowerShell. Is there not a specific file for each module you could reference?

@lions1855 let me suggest a step towards the solution for the tricky part:

q: pathnames of folders of folders (substrings separated by ";" of  values of variable "PSModulePath" of environment)
A: C:\Program Files\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation
A: C:\Program Files\WindowsPowerShell\Modules\PackageManagement
A: C:\Program Files\WindowsPowerShell\Modules\Pester
A: C:\Program Files\WindowsPowerShell\Modules\PowerShellGet
A: C:\Program Files\WindowsPowerShell\Modules\PSReadline
A: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\AppBackgroundTask
A: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\AppLocker
A: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\AppvClient
A: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Appx

You could then pull the Names of those folders and compare it vs the module name you are looking for.

Hi Brolly33,

You always come around. How would you verify if a module exists before redeploying a module? I am looking to deploy the PSWindowsUpdate module to windows 10 machines.