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 - Question about output from wmi in XP

Reply
 
Old 08-20-2007   #1 (permalink)
greatbarrier86


 
 

Question about output from wmi in XP

Is there any reason why these lines of code will return a null result in
Windows XP but NOT windows Vista?

$Get_Processor_Speed = Get-WmiObject Win32_Processor
$Processor_Speed = $Get_Processor_Speed.Name
write-host $Processor_speed

In Vista, it works fine. In XP, it fails every time.

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


 
 

RE: Question about output from wmi in XP

Works here using WinXP SP2:

PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
PS> $Processor_Speed = $Get_Processor_Speed.Name
PS> write-host $Processor_speed
Intel(R) Pentium(R) M processor 1.73GHz

Can you see the result when doing the following?

PS> Get-WmiObject Win32_Processor | select name

The same information should also be available in the registry:

PS> Get-ItemProperty HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0 |
select ProcessorNameString

--
greetings
dreeschkind

PS> Get-WmiObject Win32_Processor | select name

"greatbarrier86" wrote:

> Is there any reason why these lines of code will return a null result in
> Windows XP but NOT windows Vista?
>
> $Get_Processor_Speed = Get-WmiObject Win32_Processor
> $Processor_Speed = $Get_Processor_Speed.Name
> write-host $Processor_speed
>
> In Vista, it works fine. In XP, it fails every time.

My System SpecsSystem Spec
Old 08-20-2007   #3 (permalink)
greatbarrier86


 
 

RE: Question about output from wmi in XP

The first part you said returns nothing as the result.

the second part using the select name and Get-itemproperty work but the
result is heavily indented. Does the get-wmiobject only parse in a certain
number of lines?

"dreeschkind" wrote:

> Works here using WinXP SP2:
>
> PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
> PS> $Processor_Speed = $Get_Processor_Speed.Name
> PS> write-host $Processor_speed
> Intel(R) Pentium(R) M processor 1.73GHz
>
> Can you see the result when doing the following?
>
> PS> Get-WmiObject Win32_Processor | select name
>
> The same information should also be available in the registry:
>
> PS> Get-ItemProperty HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0 |
> select ProcessorNameString
>
> --
> greetings
> dreeschkind
>
> PS> Get-WmiObject Win32_Processor | select name
>
> "greatbarrier86" wrote:
>
> > Is there any reason why these lines of code will return a null result in
> > Windows XP but NOT windows Vista?
> >
> > $Get_Processor_Speed = Get-WmiObject Win32_Processor
> > $Processor_Speed = $Get_Processor_Speed.Name
> > write-host $Processor_speed
> >
> > In Vista, it works fine. In XP, it fails every time.

My System SpecsSystem Spec
Old 08-20-2007   #4 (permalink)
Matthias Tacke


 
 

Re: Question about output from wmi in XP

greatbarrier86 wrote:
> The first part you said returns nothing as the result.
>
> the second part using the select name and Get-itemproperty work but the
> result is heavily indented. Does the get-wmiobject only parse in a certain
> number of lines?


Well it doesn't work here on my Dual-Core notebook because the output
of $Get_Processor_Speed.Name is an array.

5# $Get_Processor_Speed.Name
6# $Get_Processor_Speed[0].Name
Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz
7# $Get_Processor_Speed[1].Name
Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz
8#

--
Greetings
Matthias
My System SpecsSystem Spec
Old 08-20-2007   #5 (permalink)
greatbarrier86


 
 

Re: Question about output from wmi in XP

but that doesnt seem to happen with my pentium D on vista...

"Matthias Tacke" wrote:

> greatbarrier86 wrote:
> > The first part you said returns nothing as the result.
> >
> > the second part using the select name and Get-itemproperty work but the
> > result is heavily indented. Does the get-wmiobject only parse in a certain
> > number of lines?

>
> Well it doesn't work here on my Dual-Core notebook because the output
> of $Get_Processor_Speed.Name is an array.
>
> 5# $Get_Processor_Speed.Name
> 6# $Get_Processor_Speed[0].Name
> Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz
> 7# $Get_Processor_Speed[1].Name
> Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz
> 8#
>
> --
> Greetings
> Matthias
>

My System SpecsSystem Spec
Old 08-20-2007   #6 (permalink)
dreeschkind


 
 

RE: Question about output from wmi in XP

"greatbarrier86" wrote:

> The first part you said returns nothing as the result.


Sorry, I don't think I understand you. I did never say something like "the
first
part returns nothing as the result". In fact I wanted to tell you that your
example works on my WinXP system! What it the "first part" you're refering to?

> the second part using the select name and Get-itemproperty work but the
> result is heavily indented.


Are you saying that this works on your system?

PS> Get-WmiObject Win32_Processor | select name

If so, then your first example should also work. However, as Matthias
pointed out, it won't work that way in case you got more than one processor
because in this case Get-WmiObject Win32_Processor will return an array of
objects and arrays don't have a name property to access. Using the
select-object cmdlet works because it will automatically iterate over all
objects in the pipeline and select the name property of each processor object.

The indentation seems to be normal, I noticed the same thing on my machine
(see my example in my first post). You can cut off the spaces using the
trim() method of the string object like so:

PS> Get-WmiObject Win32_Processor | foreach { $_.name.trim() }

> Does the get-wmiobject only parse in a certain
> number of lines?


I'm not sure what to answer here. Get-WmiObject does not parse any lines at
all. In this case it returns processor objects which are then written to the
pipeline. You can access the properties of the objects using the
select-object and foreach-object cmdlets. At the end of the pipeline these
objects/selected properties are rendered as lines of text.

Hope that helps.

You may also want to read these:
PS> help get-wmiobject -detailed
PS> help foreach-object -detailed
PS> help select-object -detailed

--
greetings
dreeschkind

> "dreeschkind" wrote:
>
> > Works here using WinXP SP2:
> >
> > PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
> > PS> $Processor_Speed = $Get_Processor_Speed.Name
> > PS> write-host $Processor_speed
> > Intel(R) Pentium(R) M processor 1.73GHz
> >
> > Can you see the result when doing the following?
> >
> > PS> Get-WmiObject Win32_Processor | select name
> >
> > The same information should also be available in the registry:
> >
> > PS> Get-ItemProperty HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0 |
> > select ProcessorNameString
> >
> > --
> > greetings
> > dreeschkind
> >
> > PS> Get-WmiObject Win32_Processor | select name
> >
> > "greatbarrier86" wrote:
> >
> > > Is there any reason why these lines of code will return a null result in
> > > Windows XP but NOT windows Vista?
> > >
> > > $Get_Processor_Speed = Get-WmiObject Win32_Processor
> > > $Processor_Speed = $Get_Processor_Speed.Name
> > > write-host $Processor_speed
> > >
> > > In Vista, it works fine. In XP, it fails every time.

My System SpecsSystem Spec
Old 08-20-2007   #7 (permalink)
dreeschkind


 
 

RE: Question about output from wmi in XP

"dreeschkind" wrote:
> "greatbarrier86" wrote:
>
> > The first part you said returns nothing as the result.

>
> Sorry, I don't think I understand you. I did never say something like "the
> first part returns nothing as the result". In fact I wanted to tell you that your
> example works on my WinXP system! What it the "first part" you're refering to?


Ah sorry, after reading your response again I understand what you mean.
Can you post the results you get with the following commands?

PS> get-member -input (Get-WmiObject Win32_Processor)

It should look something like this:

TypeName: System.Management.ManagementObject#root\cimv2\Win32_Processor

Name MemberType Definition
---- ---------- ----------
Reset Method
System.Management.ManagementBaseObject
SetPowerState Method
System.Management.ManagementBaseObject
AddressWidth Property System.UInt16 AddressWidth {get;set;}
....

If you get a TypeName: System.Object[] then Get-WmiObject indeed returns
more than one processor object on your system.

--
greetings
dreeschkind
My System SpecsSystem Spec
Old 08-20-2007   #8 (permalink)
greatbarrier86


 
 

RE: Question about output from wmi in XP

Man, this is strange. The weirder thing is that this works fine with Vista
and the PCs are Pentium Ds

"dreeschkind" wrote:

> "dreeschkind" wrote:
> > "greatbarrier86" wrote:
> >
> > > The first part you said returns nothing as the result.

> >
> > Sorry, I don't think I understand you. I did never say something like "the
> > first part returns nothing as the result". In fact I wanted to tell you that your
> > example works on my WinXP system! What it the "first part" you're refering to?

>
> Ah sorry, after reading your response again I understand what you mean.
> Can you post the results you get with the following commands?
>
> PS> get-member -input (Get-WmiObject Win32_Processor)
>
> It should look something like this:
>
> TypeName: System.Management.ManagementObject#root\cimv2\Win32_Processor
>
> Name MemberType Definition
> ---- ---------- ----------
> Reset Method
> System.Management.ManagementBaseObject
> SetPowerState Method
> System.Management.ManagementBaseObject
> AddressWidth Property System.UInt16 AddressWidth {get;set;}
> ...
>
> If you get a TypeName: System.Object[] then Get-WmiObject indeed returns
> more than one processor object on your system.
>
> --
> greetings
> dreeschkind

My System SpecsSystem Spec
Old 08-20-2007   #9 (permalink)
greatbarrier86


 
 

RE: Question about output from wmi in XP

Sorry for the trouble. Let me try to sort it out
The first part is
> PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
> PS> $Processor_Speed = $Get_Processor_Speed.Name
> PS> write-host $Processor_speed
> Intel(R) Pentium(R) M processor 1.73GHz


That just produces a null result. I was just saying that what worked for you
did not work for me.

The Get-wmiobject win32_processor | Select Name works but outputs as an
array as you mentioned.



"dreeschkind" wrote:

> "greatbarrier86" wrote:
>
> > The first part you said returns nothing as the result.

>
> Sorry, I don't think I understand you. I did never say something like "the
> first
> part returns nothing as the result". In fact I wanted to tell you that your
> example works on my WinXP system! What it the "first part" you're refering to?
>
> > the second part using the select name and Get-itemproperty work but the
> > result is heavily indented.

>
> Are you saying that this works on your system?
>
> PS> Get-WmiObject Win32_Processor | select name
>
> If so, then your first example should also work. However, as Matthias
> pointed out, it won't work that way in case you got more than one processor
> because in this case Get-WmiObject Win32_Processor will return an array of
> objects and arrays don't have a name property to access. Using the
> select-object cmdlet works because it will automatically iterate over all
> objects in the pipeline and select the name property of each processor object.
>
> The indentation seems to be normal, I noticed the same thing on my machine
> (see my example in my first post). You can cut off the spaces using the
> trim() method of the string object like so:
>
> PS> Get-WmiObject Win32_Processor | foreach { $_.name.trim() }
>
> > Does the get-wmiobject only parse in a certain
> > number of lines?

>
> I'm not sure what to answer here. Get-WmiObject does not parse any lines at
> all. In this case it returns processor objects which are then written to the
> pipeline. You can access the properties of the objects using the
> select-object and foreach-object cmdlets. At the end of the pipeline these
> objects/selected properties are rendered as lines of text.
>
> Hope that helps.
>
> You may also want to read these:
> PS> help get-wmiobject -detailed
> PS> help foreach-object -detailed
> PS> help select-object -detailed
>
> --
> greetings
> dreeschkind
>
> > "dreeschkind" wrote:
> >
> > > Works here using WinXP SP2:
> > >
> > > PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
> > > PS> $Processor_Speed = $Get_Processor_Speed.Name
> > > PS> write-host $Processor_speed
> > > Intel(R) Pentium(R) M processor 1.73GHz
> > >
> > > Can you see the result when doing the following?
> > >
> > > PS> Get-WmiObject Win32_Processor | select name
> > >
> > > The same information should also be available in the registry:
> > >
> > > PS> Get-ItemProperty HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0 |
> > > select ProcessorNameString
> > >
> > > --
> > > greetings
> > > dreeschkind
> > >
> > > PS> Get-WmiObject Win32_Processor | select name
> > >
> > > "greatbarrier86" wrote:
> > >
> > > > Is there any reason why these lines of code will return a null result in
> > > > Windows XP but NOT windows Vista?
> > > >
> > > > $Get_Processor_Speed = Get-WmiObject Win32_Processor
> > > > $Processor_Speed = $Get_Processor_Speed.Name
> > > > write-host $Processor_speed
> > > >
> > > > In Vista, it works fine. In XP, it fails every time.

My System SpecsSystem Spec
Old 08-20-2007   #10 (permalink)
Brandon Shell


 
 

Re: Question about output from wmi in XP

What happens when you do this
PS> Get-wmiobject win32_processor | %{$_.name}

The array could be due to hyperthreading.

From http://msdn2.microsoft.com/en-us/library/aa394373.aspx
To determine if hyperthreading is enabled for the processor, compare
NumberOfLogicalProcessors and NumberOfCores. If hyperthreading is enabled in
the BIOS for the processor, then NumberOfCores is less than
NumberOfLogicalProcessors. For example, a dual-processor system that
contains two processors enabled for hyperthreading can run four threads or
programs or simultaneously. In this case, NumberOfCores is 2 and
NumberOfLogicalProcessors is 4.

"greatbarrier86" <greatbarrier86@discussions.microsoft.com> wrote in message
news:7CCF9127-3861-48C6-93FE-EBC92CC341FF@microsoft.com...
> Sorry for the trouble. Let me try to sort it out
> The first part is
>> PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
>> PS> $Processor_Speed = $Get_Processor_Speed.Name
>> PS> write-host $Processor_speed
>> Intel(R) Pentium(R) M processor 1.73GHz

>
> That just produces a null result. I was just saying that what worked for
> you
> did not work for me.
>
> The Get-wmiobject win32_processor | Select Name works but outputs as an
> array as you mentioned.
>
>
>
> "dreeschkind" wrote:
>
>> "greatbarrier86" wrote:
>>
>> > The first part you said returns nothing as the result.

>>
>> Sorry, I don't think I understand you. I did never say something like
>> "the
>> first
>> part returns nothing as the result". In fact I wanted to tell you that
>> your
>> example works on my WinXP system! What it the "first part" you're
>> refering to?
>>
>> > the second part using the select name and Get-itemproperty work but the
>> > result is heavily indented.

>>
>> Are you saying that this works on your system?
>>
>> PS> Get-WmiObject Win32_Processor | select name
>>
>> If so, then your first example should also work. However, as Matthias
>> pointed out, it won't work that way in case you got more than one
>> processor
>> because in this case Get-WmiObject Win32_Processor will return an array
>> of
>> objects and arrays don't have a name property to access. Using the
>> select-object cmdlet works because it will automatically iterate over all
>> objects in the pipeline and select the name property of each processor
>> object.
>>
>> The indentation seems to be normal, I noticed the same thing on my
>> machine
>> (see my example in my first post). You can cut off the spaces using the
>> trim() method of the string object like so:
>>
>> PS> Get-WmiObject Win32_Processor | foreach { $_.name.trim() }
>>
>> > Does the get-wmiobject only parse in a certain
>> > number of lines?

>>
>> I'm not sure what to answer here. Get-WmiObject does not parse any lines
>> at
>> all. In this case it returns processor objects which are then written to
>> the
>> pipeline. You can access the properties of the objects using the
>> select-object and foreach-object cmdlets. At the end of the pipeline
>> these
>> objects/selected properties are rendered as lines of text.
>>
>> Hope that helps.
>>
>> You may also want to read these:
>> PS> help get-wmiobject -detailed
>> PS> help foreach-object -detailed
>> PS> help select-object -detailed
>>
>> --
>> greetings
>> dreeschkind
>>
>> > "dreeschkind" wrote:
>> >
>> > > Works here using WinXP SP2:
>> > >
>> > > PS> $Get_Processor_Speed = Get-WmiObject Win32_Processor
>> > > PS> $Processor_Speed = $Get_Processor_Speed.Name
>> > > PS> write-host $Processor_speed
>> > > Intel(R) Pentium(R) M processor 1.73GHz
>> > >
>> > > Can you see the result when doing the following?
>> > >
>> > > PS> Get-WmiObject Win32_Processor | select name
>> > >
>> > > The same information should also be available in the registry:
>> > >
>> > > PS> Get-ItemProperty
>> > > HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0 |
>> > > select ProcessorNameString
>> > >
>> > > --
>> > > greetings
>> > > dreeschkind
>> > >
>> > > PS> Get-WmiObject Win32_Processor | select name
>> > >
>> > > "greatbarrier86" wrote:
>> > >
>> > > > Is there any reason why these lines of code will return a null
>> > > > result in
>> > > > Windows XP but NOT windows Vista?
>> > > >
>> > > > $Get_Processor_Speed = Get-WmiObject Win32_Processor
>> > > > $Processor_Speed = $Get_Processor_Speed.Name
>> > > > write-host $Processor_speed
>> > > >
>> > > > In Vista, it works fine. In XP, it fails every time.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
generel question about console in Windows Vista - very slow output PowerShell
Enexpected output when using output-csv PowerShell
cmd output question PowerShell
Newbie output question PowerShell
No output from write-output 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