Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion versus get-wmiobject
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jason  
View profile  
 More options Jul 3 2007, 10:29 am
Newsgroups: microsoft.public.windows.powershell
From: "Jason" <nos...@nospam.com>
Date: Tue, 3 Jul 2007 09:29:01 -0500
Local: Tues, Jul 3 2007 10:29 am
Subject: Re: versus get-wmiobject

> Is there a way to use the win32_process.Create() method with get-
> wmiobject, or is that just not gonna happen?

Hi Hal:

Here's a function to do it which uses get-wmiobject and the -query
parameter:

######################################

function Create-ProcessWithWMI ($computer = ".", $commandline = $(throw
"Enter the command to execute.") )
{
    $ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE
__Class = 'Win32_Process'" -namespace "root\cimv2" -computername $computer
    $results = $ProcessClass.Create( $commandline )

    if ($results.ReturnValue -eq 0) { $results.ProcessID }  # Or just return
$true if you don't want the PID.
    else { $false ; throw "Failed to create process!" }

}

######################################

    Cheers,
        Jason

------------------------------------------------------
PowerShell Training at SANS Conferences
http://www.WindowsPowerShellTraining.com
------------------------------------------------------


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google