Windows Vista Forums

gwmi with -query parameter questions

  1. #1


    Kryten Guest

    gwmi with -query parameter questions

    Hi,

    I'm currently struggling trying to figure out how to use the -query
    parameter with gwmi for namespaces other than "root\cimv2".

    Eg.
    It's simple enough to do something like:-

    >$query = "SELECT * from Win32_Service WHERE name='W32Time'"
    >gwmi -query $query
    ExitCode : 0
    Name : W32Time
    ProcessId : 1688
    StartMode : Auto
    State : Running
    Status : OK

    but.. what if I want to get data out of "root\securitycenter" and the
    "antivirusproduct" class?
    I looked on MSDN for WQL but couldn't see any (to me) clear example of
    what the syntax should be for such a gwmi statement.

    Would appreciate any examples showing how best to construct the WQL to
    reference the namespace and class.

    Thanks,

    Stuart





      My System SpecsSystem Spec

  2. #2


    /\\/\\o\\/\\/ Guest

    Re: gwmi with -query parameter questions

    $query = "SELECT * from antivirusproduct"
    gwmi -query $query -namespace root\securitycenter

    Greetings /\/\o\/\/
    http://thePowerShellGuy.com

    "Kryten" <Kryten68@xxxxxx> wrote in message
    news:634bfcdc-c652-4448-9c9c-c2bf7945cff0@xxxxxx

    > Hi,
    >
    > I'm currently struggling trying to figure out how to use the -query
    > parameter with gwmi for namespaces other than "root\cimv2".
    >
    > Eg.
    > It's simple enough to do something like:-
    >

    >>$query = "SELECT * from Win32_Service WHERE name='W32Time'"
    >>gwmi -query $query
    >
    > ExitCode : 0
    > Name : W32Time
    > ProcessId : 1688
    > StartMode : Auto
    > State : Running
    > Status : OK
    >
    > but.. what if I want to get data out of "root\securitycenter" and the
    > "antivirusproduct" class?
    > I looked on MSDN for WQL but couldn't see any (to me) clear example of
    > what the syntax should be for such a gwmi statement.
    >
    > Would appreciate any examples showing how best to construct the WQL to
    > reference the namespace and class.
    >
    > Thanks,
    >
    > Stuart
    >
    >

      My System SpecsSystem Spec

gwmi with -query parameter questions

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using multiple Parameter sets for a Parameter AgentM PowerShell 2 29 Jul 2008
-query not a parameter? Mark PowerShell 9 07 Sep 2007
How to best control parameter attributes and parameter parsing in your own scripts? Audun Gjerken PowerShell 1 04 Mar 2007
Get-EventLog vs gwmi -query $hay PowerShell 4 30 Jan 2007
get-WmiObject -Query parameter /\\/\\o\\/\\/ PowerShell 0 25 May 2006