How do I run specific queries in SCCM using Powershell

5,058

Do you mean that you want to use PowerShell to run a CM Query? Then you can use built-in cmdlet:

Invoke-CMQuery -Name 'YourQueryName'

To get the detailed syntax of Invoke-CMQuery command, you can run below:

Get-Help Invoke-CMQuery

The output is different with running from GUI, however, you may still be able to use PowerShell to change the output style.

Share:
5,058

Related videos on Youtube

AID
Author by

AID

Updated on September 18, 2022

Comments

  • AID
    AID over 1 year

    Could you advise how could I run query ID using command prompt? For example, I do not want to go to Monitoring-Queries-expand tree and search for the specific querry. I Just want to have script file, when I launch it the command show the result of my query or export it to csv file. What is the syntaxis if I should go to File - connect via Windows Poweshell?

    MS SCCM 2012 console version 5 site version 5

    • Jeter-work
      Jeter-work almost 7 years
      Your question's 'Title' should contain the question. The info in your title should be in the body. I think you are asking "How do I monitor queries in SCCM using Powershell?"