Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How can you remotely instantiate a WMI class?

Reply
 
Old 05-11-2007   #1 (permalink)
Janssen


 
 

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

My System SpecsSystem Spec
Old 05-11-2007   #2 (permalink)
Brandon Shell


 
 

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


My System SpecsSystem Spec
Old 05-11-2007   #3 (permalink)
Janssen


 
 

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

>
>

My System SpecsSystem Spec
Old 05-11-2007   #4 (permalink)
Brandon Shell


 
 

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

>>
>>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
When a class is both an inherited class of another, and alsoimplements an interface method .NET General
win32_pingstatus class / dns class PowerShell
Can't connect remotely Vista networking & sharing
Instantiate Win32 DLL COM server in Vista's IIS Vista General
How to instantiate a COM object using moniker syntax? PowerShell


Vista Forums 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 Ltd

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