Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Exchange Build number (long format)

Exchange Build number (long format)

Scheduled Pinned Locked Moved Support
6 Posts 2 Posters 26.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    Thomas
    wrote on last edited by
    #1

    Hi,

    After Update to Version 4.X the old dosent work

    Netxms config:
    ExternalParameter = EXVersion:"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" "C:\Script\EXVersion.ps1"
    Script: Get-Command Exsetup.exe | ForEach FileVersionInfo |fl Productversion

    No Version Information.

    After Searching i use this:

    ExternalParameterShellExec = ExchangePatchNumber:pwsh -Command { Get-Command Exsetup.exe | ForEach {$_.FileVersionInfo} }

    Value: forEach' is not recognized as an internal or external command

    Debug log:
    2022.05.20 13:11:46.415 *D* [exec              ] RunExternal called for "ExchangePatchNumber" "Spwsh -Command { Get-Command Exsetup.exe | ForEach {$_.FileVersionInfo} }"
    2022.05.20 13:11:46.415 *D* [exec              ] RunExternal: command line is "pwsh -Command { Get-Command Exsetup.exe | ForEach {_.FileVersionInfo} }"
    2022.05.20 13:11:46.423 *D* [procexec          ] ProcessExecutor::execute(): process "CMD.EXE /C pwsh -Command { Get-Command Exsetup.exe | ForEach {_.FileVersionInfo} }" started
    2022.05.20 13:11:46.467 *D* [procexec          ] ProcessExecutor::readOutput(): stopped on GetOverlappedResult (The pipe has been ended.)
    2022.05.20 13:11:46.467 *D* [comm.cs.1          ] GetMetricValue("ExchangePatchNumber"): 0 (SUCCESS) value = "'ForEach' is not recognized as an internal or external command,"

    If I understand correctly then he leaves the variable $ ( 022.05.20 13:11:46.423 *D* [procexec          ] ProcessExecutor::execute(): process "CMD.EXE /C pwsh -Command { Get-Command Exsetup.exe | ForEach {_.FileVersionInfo} }" started) out and that's why the error occurs?

    In Powershell the Command works

    Any ideas about it?

    Thanks

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      you should use $$ to insert $ into command, as it is start of command argument ($1, $2, etc.).

      Best regards,
      Victor

      1 Reply Last reply
      0
      • T
        T
        Thomas
        wrote on last edited by
        #3

        Hello Victor,

        Thanks for your answer.. This woks..

        But in NetXMS the Value is emty....

        Log:
        2022.05.23 14:07:23.515 *D* [procexec          ] ProcessExecutor::execute(): process "CMD.EXE /C powershell -Command "& { Get-Command Exsetup.exe | ForEach {$_.FileVersionInfo} }"" started
        2022.05.23 14:07:23.746 *D* [procexec          ] ProcessExecutor::readOutput(): stopped on GetOverlappedResult (The pipe has been ended.)
        2022.05.23 14:07:23.746 *D* [comm.cs.1          ] GetMetricValue("ExchangePatchNumber"): 0 (SUCCESS) value = ""

        CMD out:
        C:\>CMD.EXE /C powershell -Command "& { Get-Command Exsetup.exe | ForEach {$_.FileVersionInfo} }"

        ProductVersion  FileVersion      FileName
        --------------  -----------      --------
        15.02.1118.007  15.02.1118.007  D:\Program Files\Microsoft\Exchange Server\V15\bin\ExSetup.exe

        Is the problem here that only the first line is output and the value is actually in the 3 line?
        Do you have an idea how I can fix this?

        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #4

          Yes, only first line is taken as value of external parameter. You have to format output in your script so it return required value in first line.

          Best regards,
          Victor

          1 Reply Last reply
          0
          • T
            T
            Thomas
            wrote on last edited by
            #5

            OK but powershell output beginns ever wither a blank line i have no idea how do i get rid of that

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #6

              Not each output of powershell begins with empty line, only this specific command does. You can filter output further, probably from powershell itself as well, but I don't know how (not using it). However, command line pipe should work as well (I assume you are interested in line with version number):

              ExternalParameterShellExec = ExchangePatchNumber:pwsh -Command { Get-Command Exsetup.exe | ForEach {$_.FileVersionInfo} } | find "ExSetup.exe"
              

              Best regards,
              Victor

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              Powered by NodeBB Contributors
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups