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 - WMI

Reply
 
Old 08-08-2007   #1 (permalink)
Marek


 
 

WMI

Hi all,
sorry for my bad Englisch. I have basic questation about powershell and wmi.
I want get instaces for win32_shares class . try:

$mc = new-object system.management.managementclass("win32_shares")
$mc. getinstances()
but command return error . Use powershell framework classes , and how I call
correctly getinstances ?

thanx
marek

My System SpecsSystem Spec
Old 08-08-2007   #2 (permalink)


XP 2003 SuSE
 
 

Re: WMI

To get anything WMI in the Powershell, simply
Get-WmiObject -Class Win32_BIOS

See this article. It explains it all for you.


To get the instances, simply say;
$disk= WmiObject Win32_LogicalDisk "Drive Letter Size GB "
foreach ($drive in $disk ) {"Drive = " + $drive.Name}

Cheers

L
My System SpecsSystem Spec
Old 08-09-2007   #3 (permalink)
Marek


 
 

Re: WMI

Thanx for answer.
And if I use create wmi class with preview email , where is error ?

"lrbell" wrote:

>
> To get anything WMI in the Powershell, simply
> Get-WmiObject -Class Win32_BIOS
>
> See this 'article'
> (http://www.microsoft.com/technet/scr...wmiobject.mspx).
> It explains it all for you.
>
> Cheers.
>
> L
>
>
> --
> lrbell
>

My System SpecsSystem Spec
Old 08-09-2007   #4 (permalink)
Thomas Lee


 
 

Re: WMI

In message <8D2CACF5-95EA-49CF-9864-9573FFD87323@microsoft.com>, Marek
<Marek@discussions.microsoft.com> writes
>Thanx for answer.
>And if I use create wmi class with preview email , where is error ?


I am not quite sure what you are asking - but there is no wmi class
called win32_shares. There _is_ a win32_share class, as shown here:


PSH [D:\foo]: gwmi win32_share

Name Path
Description
---- ----
-----------
E$ E:\
Default share
IPC$
Remote IPC
D$ D:\
Default share
ADMIN$ C:\WINDOWS
Remote Admin
C$ C:\
Default share


PSH [D:\foo]: (gwmi win32_share).count
5

HTH

THomas


--
Thomas Lee
doctordns@gmail.com
MVP - Admin Frameworks and Security
My System SpecsSystem Spec
Old 08-09-2007   #5 (permalink)
Marek


 
 

Re: WMI

I want connect to the serverfrom second child domain . I write :
$p = new-object system.management.managementclass
$p.psbase.path="\\fuuslnt2.usl.ul.ds.mfcr.cz\root\microsoftdns:microsoftdns_zone"
$p.psbase.getinstances()
Exception retrieving members: "The RPC server is unavailable. (Exception
from HRESULT: 0x800706BA)"

if I try :
PS H:\> $p = new-object system.management.managementclass
PS H:\> $p.psbase.path="\\fuuslnt2.usl.ul.ds.mfcr.cz\root\cimv2:win32_share"
PS H:\> $p.psbase.getinstances()

this work ....

where is trouble ?

thanx marek
My System SpecsSystem Spec
Old 08-09-2007   #6 (permalink)
Marek


 
 

Re: WMI

if I copy code from VS C# , where the code run ok, powershell return this

PS H:\> $ms = new-object System.Management.ManagementScope($pt)
PS H:\> $ms.Options.Impersonation = "Impersonate"
PS H:\> $ms.Options.Password = "xxx";
PS H:\> $ms.Options.Authority = "NTLMDOMAIN:UL";
PS H:\> $ms.Options.Username = "yyy";
PS H:\> $ms.psbase.Connect();
PS H:\> $mc = new-object system.management.ManagementClass($pt);
PS H:\> $mc.psbase.scope = $ms
PS H:\> $mc.psbase.GetInstances()
Exception calling "GetInstances" with "0" argument(s): "Operation is not
valid due to the current state of the object."
At line:1 char:24


"Thomas Lee" wrote:

> In message <8D2CACF5-95EA-49CF-9864-9573FFD87323@microsoft.com>, Marek
> <Marek@discussions.microsoft.com> writes
> >Thanx for answer.
> >And if I use create wmi class with preview email , where is error ?

>
> I am not quite sure what you are asking - but there is no wmi class
> called win32_shares. There _is_ a win32_share class, as shown here:
>
>
> PSH [D:\foo]: gwmi win32_share
>
> Name Path
> Description
> ---- ----
> -----------
> E$ E:\
> Default share
> IPC$
> Remote IPC
> D$ D:\
> Default share
> ADMIN$ C:\WINDOWS
> Remote Admin
> C$ C:\
> Default share
>
>
> PSH [D:\foo]: (gwmi win32_share).count
> 5
>
> HTH
>
> THomas
>
>
> --
> Thomas Lee
> doctordns@gmail.com
> MVP - Admin Frameworks and Security
>

My System SpecsSystem Spec
Old 08-09-2007   #7 (permalink)
Desmond Lee


 
 

RE: WMI

Try

Get-Wmiobject -class win32_ntshare -computer remoteServerNameOrIP

HTH.

--
............... All new, all fresh ..............
http://www.leedesmond.com/weblog/



"Marek" wrote:

> Hi all,
> sorry for my bad Englisch. I have basic questation about powershell and wmi.
> I want get instaces for win32_shares class . try:
>
> $mc = new-object system.management.managementclass("win32_shares")
> $mc. getinstances()
> but command return error . Use powershell framework classes , and how I call
> correctly getinstances ?
>
> thanx
> marek

My System SpecsSystem Spec
Old 08-10-2007   #8 (permalink)
Thomas Lee


 
 

Re: WMI

In message <6DB45474-A8A1-463E-B393-F403931E057C@microsoft.com>, Desmond
Lee <mcp@donotspamplease.mars> writes
>Try
>
>Get-Wmiobject -class win32_ntshare -computer remoteServerNameOrIP
>
>HTH.
>


PSH [D:\foo]: Get-Wmiobject -class win32_ntshare
Get-WmiObject : Invalid class
At line:1 char:14
+ Get-Wmiobject <<<< -class win32_ntshare

The correct class name is win32_share, as in:


PSH [D:\foo]: Get-Wmiobject -class win32_share

Name Path Description
---- ---- -----------
E$ E:\ Default share
IPC$ Remote IPC
D$ D:\ Default share
ADMIN$ C:\WINDOWS Remote Admin
C$ C:\ Default share

HTH

Thomas

--
Thomas Lee
doctordns@gmail.com
MVP - Admin Frameworks and Security
My System SpecsSystem Spec
Reply

Thread Tools



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