Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How can you remotely instantiate a WMI class?

Closed Thread
 
Thread Tools Display Modes
Old 05-11-2007   #1 (permalink)
Janssen
Guest


 

How can you remotely instantiate a WMI class?

Hello again,

I have a script setup to create a printer locally using WMI, using the
following code:

$PRINTERCLASS = [WMICLASS]"WIN32_PRINTER"
$MYPRINTER = $PRINTERCLASS.CREATEINSTANCE()

I know that I can remotely hit wmi via gwmi -comp remotecomputer
win32_printer, but I'm not sure how one would go about instantiating an
object remotely, since there doesn't seem to be a built-in way to do that
with powershell's WMI provider, at least that I can see (I'm still pretty new
to all of this).

Any help would be much appreciated.

Thanks,

Janssen
Old 05-11-2007   #2 (permalink)
Brandon Shell
Guest


 

Re: How can you remotely instantiate a WMI class?

$printerClass = Get-WmiObject Win32_Printer -ComputerName <ServerNameHere>

I suggest reading this... some cool stuff you can do.
Get-help Get-WmiObject -full

"Janssen" <Janssen@discussions.microsoft.com> wrote in message
news:57EDA02D-83F2-4AEF-B6DB-62F9C6DA8669@microsoft.com...
> Hello again,
>
> I have a script setup to create a printer locally using WMI, using the
> following code:
>
> $PRINTERCLASS = [WMICLASS]"WIN32_PRINTER"
> $MYPRINTER = $PRINTERCLASS.CREATEINSTANCE()
>
> I know that I can remotely hit wmi via gwmi -comp remotecomputer
> win32_printer, but I'm not sure how one would go about instantiating an
> object remotely, since there doesn't seem to be a built-in way to do that
> with powershell's WMI provider, at least that I can see (I'm still pretty
> new
> to all of this).
>
> Any help would be much appreciated.
>
> Thanks,
>
> Janssen


Old 05-11-2007   #3 (permalink)
Janssen
Guest


 

Re: How can you remotely instantiate a WMI class?

Brandon,

Thanks for the reply.

The issue is that if you use gwmi win32_printer, you don't get access to the
createinstance() method. You only get access to the printers already in
existence. The only way I've found to get access to createintstance is to
use [WMICLASS], which doesn't actually give you the real objects, but access
to a blank class.

However, I did figure out the proper syntax I was looking for, which is:
[wmiclass]"\\servername\root\cimv2:win32_printer"

Janssen

"Brandon Shell" wrote:

> $printerClass = Get-WmiObject Win32_Printer -ComputerName <ServerNameHere>
>
> I suggest reading this... some cool stuff you can do.
> Get-help Get-WmiObject -full
>
> "Janssen" <Janssen@discussions.microsoft.com> wrote in message
> news:57EDA02D-83F2-4AEF-B6DB-62F9C6DA8669@microsoft.com...
> > Hello again,
> >
> > I have a script setup to create a printer locally using WMI, using the
> > following code:
> >
> > $PRINTERCLASS = [WMICLASS]"WIN32_PRINTER"
> > $MYPRINTER = $PRINTERCLASS.CREATEINSTANCE()
> >
> > I know that I can remotely hit wmi via gwmi -comp remotecomputer
> > win32_printer, but I'm not sure how one would go about instantiating an
> > object remotely, since there doesn't seem to be a built-in way to do that
> > with powershell's WMI provider, at least that I can see (I'm still pretty
> > new
> > to all of this).
> >
> > Any help would be much appreciated.
> >
> > Thanks,
> >
> > Janssen

>
>

Old 05-11-2007   #4 (permalink)
Brandon Shell
Guest


 

Re: How can you remotely instantiate a WMI class?

Whoops... I misunderstood your question. )

"Janssen" <Janssen@discussions.microsoft.com> wrote in message
news:3FBD2670-329F-47CE-8BCA-25B99F95315C@microsoft.com...
> Brandon,
>
> Thanks for the reply.
>
> The issue is that if you use gwmi win32_printer, you don't get access to
> the
> createinstance() method. You only get access to the printers already in
> existence. The only way I've found to get access to createintstance is to
> use [WMICLASS], which doesn't actually give you the real objects, but
> access
> to a blank class.
>
> However, I did figure out the proper syntax I was looking for, which is:
> [wmiclass]"\\servername\root\cimv2:win32_printer"
>
> Janssen
>
> "Brandon Shell" wrote:
>
>> $printerClass = Get-WmiObject Win32_Printer -ComputerName
>> <ServerNameHere>
>>
>> I suggest reading this... some cool stuff you can do.
>> Get-help Get-WmiObject -full
>>
>> "Janssen" <Janssen@discussions.microsoft.com> wrote in message
>> news:57EDA02D-83F2-4AEF-B6DB-62F9C6DA8669@microsoft.com...
>> > Hello again,
>> >
>> > I have a script setup to create a printer locally using WMI, using the
>> > following code:
>> >
>> > $PRINTERCLASS = [WMICLASS]"WIN32_PRINTER"
>> > $MYPRINTER = $PRINTERCLASS.CREATEINSTANCE()
>> >
>> > I know that I can remotely hit wmi via gwmi -comp remotecomputer
>> > win32_printer, but I'm not sure how one would go about instantiating an
>> > object remotely, since there doesn't seem to be a built-in way to do
>> > that
>> > with powershell's WMI provider, at least that I can see (I'm still
>> > pretty
>> > new
>> > to all of this).
>> >
>> > Any help would be much appreciated.
>> >
>> > Thanks,
>> >
>> > Janssen

>>
>>


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PS WMI problem remotely Thomas Makro PowerShell 6 03-19-2008 05:07 AM
Run Dcpromo remotely Santhosh PowerShell 8 01-26-2008 06:01 AM
Instantiate Win32 DLL COM server in Vista's IIS Krygim Vista General 0 11-25-2007 04:12 AM
Printing Remotely Dan Vista print fax & scan 0 11-23-2007 11:41 AM
How to instantiate a COM object using moniker syntax? Daymon PowerShell 2 04-07-2007 01:49 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50