/build/static/layout/Breadcrumb_cap_w.png

How do you create a custom inventory rule for figuring out a machine's Powershell Version?

ShellCommandtextReturn(%systemroot%\sysnative\windowspowershell\v1.0\powershell.exe $PSVersionTable.PSVersion | Select-String -pattern 4,4.0)

I only want to create a rule for Powershell version 4. So the idea i had was to get the version number from the $PSVersionTable. This returns an actual table and I really only want one number. So I used the Select-string -pattern of 4. In the powershell window on a computer, it returns 4.0. So the comma 4.0 at the end of the statement is supposed to match the output on the command but doesn't.

Any ideas?

2 Comments   [ + ] Show comments
  • Try ($PSVersionTable).PSVersion | Select -Expand Major - flip1001 9 years ago
  • Or if you only want powershell 4

    ($PSVersionTable).PSVersion | Where-Object {$_.Major -eq '4'} | Select -Expand Major - flip1001 9 years ago

Answers (0)

Be the first to answer this question

 
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