![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||